Update byteManager.py

This commit is contained in:
chrys 2019-08-20 16:05:13 +02:00 committed by GitHub
parent ba6826284f
commit 69632cb0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,12 +29,36 @@ class byteManager():
if convertedEscapeSequence[0] == 94 and convertedEscapeSequence[1] ==91: if convertedEscapeSequence[0] == 94 and convertedEscapeSequence[1] ==91:
convertedEscapeSequence = b'^[' + convertedEscapeSequence[2:] convertedEscapeSequence = b'^[' + convertedEscapeSequence[2:]
return convertedEscapeSequence return convertedEscapeSequence
def handleByteStream(self, eventData, sep = b'\x1b'):
buffer = eventData
# handle prefix
endIndex = buffer.find(sep)
if endIndex > 0:
currSequence = buffer[:endIndex]
buffer = buffer[endIndex:]
self.handleSingleByteSequence(currSequence)
# special handlig for none found (performance)
elif endIndex == -1:
self.handleSingleByteSequence(buffer)
return
# handle outstanding sequence
while buffer != b'':
endIndex = buffer[len(sep):].find(sep)
if endIndex == -1:
currSequence = buffer
buffer = b''
else:
currSequence = buffer[:endIndex + len(sep)]
buffer = buffer[endIndex + len(sep):]
self.handleSingleByteSequence(currSequence)
def handleByteInput(self, eventData): def handleByteInput(self, eventData):
if not eventData: if not eventData:
return return
if eventData == b'': if eventData == b'':
return return
self.handleByteStream(eventData)
#self.handleSingleByteSequence(eventData)
def handleSingleByteSequence(self, eventData):
convertedEscapeSequence = self.unifyEscapeSeq(eventData) convertedEscapeSequence = self.unifyEscapeSeq(eventData)
if self.switchCtrlModeOnce > 0: if self.switchCtrlModeOnce > 0: