cleanup indention speak

This commit is contained in:
chrys 2018-03-24 21:29:54 +01:00
parent 67551a83f8
commit 59203ab838
3 changed files with 16 additions and 13 deletions

View File

@ -42,13 +42,9 @@ class command():
self.lastIdent = currIdent self.lastIdent = currIdent
doInterrupt = True doInterrupt = True
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'): if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'):
if self.lastIdent < currIdent: if self.lastIdent != currIdent:
self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent - self.lastIdent) + ' ', interrupt=doInterrupt, flush=False) self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent) + ' ', interrupt=doInterrupt, flush=False)
doInterrupt = False doInterrupt = False
elif self.lastIdent > currIdent:
self.env['runtime']['outputManager'].presentText(_('outdented ') + str(self.lastIdent - currIdent) + ' ', interrupt=doInterrupt, flush=False)
doInterrupt = False
self.env['runtime']['outputManager'].presentText(currLine, interrupt=doInterrupt, flush=False) self.env['runtime']['outputManager'].presentText(currLine, interrupt=doInterrupt, flush=False)
self.lastIdent = currIdent self.lastIdent = currIdent
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -86,6 +86,7 @@ class screenManager():
if oldScreenText == '' and\ if oldScreenText == '' and\
newScreenText != '': newScreenText != '':
self.env['screen']['newDelta'] = newScreenText self.env['screen']['newDelta'] = newScreenText
print(1)
else: else:
cursorLineStart = self.env['screen']['newCursor']['y'] * self.env['screen']['columns'] + self.env['screen']['newCursor']['y'] cursorLineStart = self.env['screen']['newCursor']['y'] * self.env['screen']['columns'] + self.env['screen']['newCursor']['y']
cursorLineEnd = cursorLineStart + self.env['screen']['columns'] cursorLineEnd = cursorLineStart + self.env['screen']['columns']
@ -110,10 +111,12 @@ class screenManager():
if tempNewDelta != ''.join(newScreenText[self.env['screen']['oldCursor']['x']:self.env['screen']['newCursor']['x']].rstrip()): if tempNewDelta != ''.join(newScreenText[self.env['screen']['oldCursor']['x']:self.env['screen']['newCursor']['x']].rstrip()):
diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]] diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]]
typing = True typing = True
print(2)
else: else:
diff = difflib.ndiff( oldScreenText.split('\n'),\ diff = difflib.ndiff( oldScreenText.split('\n'),\
newScreenText.split('\n')) newScreenText.split('\n'))
diffList = list(diff) diffList = list(diff)
print(3)
if self.env['runtime']['settingsManager'].getSetting('general', 'newLinePause') and not typing: if self.env['runtime']['settingsManager'].getSetting('general', 'newLinePause') and not typing:
self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+') self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+')

View File

@ -41,7 +41,12 @@ class Terminal:
for char in (line[x] for x in range(self.screen.columns))] for char in (line[x] for x in range(self.screen.columns))]
allAttributes.append((attributes)) allAttributes.append((attributes))
self.screen.dirty.clear() self.screen.dirty.clear()
return {"cursor": (cursor.x, cursor.y), "lines": text, 'attributes': allAttributes}.copy() return {"cursor": (cursor.x, cursor.y),
'lines': self.screen.lines,
'columns': self.screen.columns,
"text": text,
'attributes': allAttributes
}.copy()
class driver(screenDriver): class driver(screenDriver):
def __init__(self): def __init__(self):
@ -54,8 +59,8 @@ class driver(screenDriver):
self.env = environment self.env = environment
self.env['runtime']['processManager'].addCustomEventThread(self.terminalEmulation) self.env['runtime']['processManager'].addCustomEventThread(self.terminalEmulation)
def getCurrScreen(self): def getCurrScreen(self):
self.env['screen']['oldTTY'] = str(1) self.env['screen']['oldTTY'] = '1'
self.env['screen']['newTTY'] = str(1) self.env['screen']['newTTY'] = '1'
def injectTextToScreen(self, text, screen = None): def injectTextToScreen(self, text, screen = None):
pass pass
@ -164,16 +169,15 @@ class driver(screenDriver):
def createScreenEventData(self, content): def createScreenEventData(self, content):
eventData = { eventData = {
'bytes': content, 'bytes': content,
'lines': int( 37), 'lines': content['lines'],
'columns': int( 138 'columns': content['columns'],
),
'textCursor': 'textCursor':
{ {
'x': int( content['cursor'][0]), 'x': int( content['cursor'][0]),
'y': int( content['cursor'][1]) 'y': int( content['cursor'][1])
}, },
'screen': '1', 'screen': '1',
'text': content['lines'], 'text': content['text'],
'attributes': content['attributes'], 'attributes': content['attributes'],
'screenUpdateTime': time.time(), 'screenUpdateTime': time.time(),
} }