cleanup + syntax

This commit is contained in:
chrys 2018-05-30 18:33:08 +02:00
parent 5e4f4832c1
commit f74ac1f84f
2 changed files with 9 additions and 7 deletions

View File

@ -52,7 +52,7 @@ class byteManager():
if time.time() - self.lastInputTime <= self.env['runtime']['settingsManager'].getSettingAsFloat('keyboard','doubleTapTimeout'): if time.time() - self.lastInputTime <= self.env['runtime']['settingsManager'].getSettingAsFloat('keyboard','doubleTapTimeout'):
self.repeat += 1 self.repeat += 1
shortcutData = b'' shortcutData = b''
for i to range(self.repeat): for i in range(self.repeat):
shortcutData = shortcutData + convertedEscapeSequence shortcutData = shortcutData + convertedEscapeSequence
isCommand = self.detectByteCommand(shortcutData) isCommand = self.detectByteCommand(shortcutData)
# fall back to single stroke - do we want this? # fall back to single stroke - do we want this?

View File

@ -40,12 +40,12 @@ class Terminal:
buffer = self.screen.buffer buffer = self.screen.buffer
self.attributes = [[list(attribute[1:]) + [False, 'default', 'default'] for attribute in line.values()] for line in buffer.values()] self.attributes = [[list(attribute[1:]) + [False, 'default', 'default'] for attribute in line.values()] for line in buffer.values()]
self.screen.dirty.clear() self.screen.dirty.clear()
return {"textCursor": (cursor.x, cursor.y), return {"cursor": (cursor.x, cursor.y),
'lines': self.screen.lines, 'lines': self.screen.lines,
'columns': self.screen.columns, 'columns': self.screen.columns,
"text": self.text, "text": self.text,
'attributes': self.attributes.copy(), 'attributes': self.attributes.copy(),
'screen': 'pty' 'screen': 'pty',
'screenUpdateTime': time.time(), 'screenUpdateTime': time.time(),
}.copy() }.copy()
@ -75,9 +75,10 @@ class driver(screenDriver):
self.env['screen']['autoIgnoreScreens'] = [] self.env['screen']['autoIgnoreScreens'] = []
self.env['general']['prevUser'] = getpass.getuser() self.env['general']['prevUser'] = getpass.getuser()
self.env['general']['currUser'] = getpass.getuser() self.env['general']['currUser'] = getpass.getuser()
def readAll(self,fd, timeout = 9999999, interruptFd = None, len = 4096): def readAll(self, fd, timeout = 9999999, interruptFd = None, len = 4096):
bytes = b'' bytes = b''
fdList = [fd] fdList = []
fdList += [fd]
if interruptFd: if interruptFd:
fdList += [interruptFd] fdList += [interruptFd]
starttime = time.time() starttime = time.time()
@ -85,12 +86,13 @@ class driver(screenDriver):
# respect timeout but wait a little bit of time to see if something more is here # respect timeout but wait a little bit of time to see if something more is here
if (time.time() - starttime) >= timeout: if (time.time() - starttime) >= timeout:
break break
r = screen_utils.hasMoreWhat(fdList,0.05): r = screen_utils.hasMoreWhat(fdList,0)
hasmore = fd in r hasmore = fd in r
if not hasmore: if not hasmore:
break break
# exit on interrupt available # exit on interrupt available
if interruptFd in r: if interruptFd in r:
print('i')
break break
data = os.read(fd, len) data = os.read(fd, len)
if data == b'': if data == b'':
@ -160,7 +162,7 @@ class driver(screenDriver):
# output # output
if self.p_out in r: if self.p_out in r:
try: try:
msgBytes = self.readAll(self.p_out.fileno(), timeout=0.5, interruptFd=sys.stdin.fileno()) msgBytes = self.readAll(self.p_out.fileno(), timeout=0.2, interruptFd=sys.stdin)
except (EOFError, OSError): except (EOFError, OSError):
active.value = False active.value = False
break break