From cd39f2ee29e23b02238036dcf70b38851e6218aa Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 19 Jul 2016 10:29:28 +0200 Subject: [PATCH] improve speed if tty changes --- src/fenrir-package/screen/linux.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index e0961c9f..07ea2e9c 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -57,14 +57,17 @@ class screen(): environment['screenData']['oldCursor']['y'] = 0 environment['screenData']['oldDelta'] = '' environment['screenData']['newDelta'] = '' - + # changes on the screen if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ (len(environment['screenData']['newContentText']) > 0): # diff = difflib.ndiff(environment['screenData']['oldContentText'], environment['screenData']['newContentText']) - - diff = difflib.ndiff(" ".join(environment['screenData']['oldContentText'].split(' ')), " ".join(environment['screenData']['newContentText'].split(' '))) - environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ ')) + if environment['screenData']['oldContentText'] == '' and\ + environment['screenData']['newContentText'] != '': + environment['screenData']['newDelta'] = environment['screenData']['newContentText'] + else: + diff = difflib.ndiff(" ".join(environment['screenData']['oldContentText'].split(' ')), " ".join(environment['screenData']['newContentText'].split(' '))) + environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ ')) return environment