1
0

little progress

This commit is contained in:
acn 2016-06-01 17:14:09 +02:00
parent 793da44300
commit 3a1edb0d18
2 changed files with 21 additions and 4 deletions

View File

@ -61,6 +61,17 @@ class rtxMask:
zeile = zeile[:pos-1] + char + zeile[pos:] zeile = zeile[:pos-1] + char + zeile[pos:]
answers[line] = zeile answers[line] = zeile
def _cut_off_rest_of_line(self, line, pos):
""" erases the rest of the line from the 'lines' variable and from the screen """
zeile = self.answers[line]
self.answers[line] = zeile[:pos]
if zeile[pos:] != "":
numOfSpaces = len(zeile[pos:])
spaces = " " * numOfSpaces
backSpaces = "\x08" * numOfSpaces
glob.ser.write(bytes(spaces + backSpaces, "latin-1"))
def process_input(self): def process_input(self):
""" reads the input from the client, fills the mask and gets the input """ """ reads the input from the client, fills the mask and gets the input """
@ -70,12 +81,13 @@ class rtxMask:
# position the cursor into the first field # position the cursor into the first field
self._pos_cur_to_line(lines[1]) self._pos_cur_to_line(lines[1])
posx = 1 # cursor position inside the line posx = 0 # cursor position inside the line - max. position is length-1
posy = 0 # the current line posy = 0 # the current line - max. number is len(lines)-1
weiter = True weiter = True
# read input and interpret it # read input and interpret it
while weiter==True: while weiter==True:
# if the modem hangs up, exit the function:
#if config.MODE == "modem" and glob.ser.getCD() == False: #if config.MODE == "modem" and glob.ser.getCD() == False:
# weiter=False # weiter=False
in_byte = glob.ser.read(1) in_byte = glob.ser.read(1)
@ -83,7 +95,10 @@ class rtxMask:
echostr = instr echostr = instr
if instr == cept.TER or instr == cept.CR: if instr == cept.TER or instr == cept.CR:
# TODO: weiter in nächster Zeile if posy == len(lines)-1:
# this was the last line, now send the data
# TODO
weiter = False
elif instr.isalnum(): elif instr.isalnum():
self._set_str_at_pos(instr, posx, posy) self._set_str_at_pos(instr, posx, posy)
posx += 1 posx += 1
@ -94,7 +109,6 @@ class rtxMask:
echostr = "" echostr = ""
# lineinput == Zeilenende beachten # lineinput == Zeilenende beachten
# dafür aber die Konstruktion von lines nochmal umbauen, um auf "length" zugreifen zu können...
glob.ser.write(bytes(echostr, "latin-1")) glob.ser.write(bytes(echostr, "latin-1"))

View File

@ -12,6 +12,9 @@ import config
import logging import logging
def init_modem(): def init_modem():
logging.debug("clearing input/output buffers")
glob.ser.reset_input_buffer()
glob.ser.reset_output_buffer()
""" send the modem init strings to the modem """ """ send the modem init strings to the modem """
logging.debug("init_modem") logging.debug("init_modem")
if config.MODEM_INIT1 != "": if config.MODEM_INIT1 != "":