From b0c43e26a22d78e467f3683ee5be1f53b605281a Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 22:28:41 +0200 Subject: [PATCH 1/5] remove hack that may cause a bug --- src/fenrir-package/screen/linux.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index b1d0ea60..450fb318 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -71,25 +71,21 @@ class screen(): # changes on the screen if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ (environment['screenData']['newContentText'] != '' ): - if environment['screenData']['oldContentText'] == '' and\ - environment['screenData']['newContentText'] != '': - environment['screenData']['newDelta'] = environment['screenData']['newContentText'] + diffStart = 0 + if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ + environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ + environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: + diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] + diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ + environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) else: - diffStart = 0 - if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ - environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ - environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: - diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] - diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ - environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) - else: - diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ - environment['screenData']['newContentText'][diffStart:].split('\n')) - - diffList = list(diff) + diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ + environment['screenData']['newContentText'][diffStart:].split('\n')) + + diffList = list(diff) - environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) - environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) + environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) + environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) else: environment['screenData']['newNegativeDelta'] = '' environment['screenData']['newDelta'] = '' From da189bb19eb2878a10bf0e6db07f48136643dcd4 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 22:33:41 +0200 Subject: [PATCH 2/5] cleanup --- src/fenrir-package/screen/linux.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index 450fb318..32cb9fa9 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -64,10 +64,10 @@ class screen(): environment['screenData']['oldCursor']['x'] = 0 environment['screenData']['oldCursor']['y'] = 0 environment['screenData']['oldDelta'] = '' - environment['screenData']['newDelta'] = '' environment['screenData']['oldNegativeDelta'] = '' - environment['screenData']['newNegativeDelta'] = '' - + # always clear deltas + environment['screenData']['newNegativeDelta'] = '' + environment['screenData']['newDelta'] = '' # changes on the screen if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ (environment['screenData']['newContentText'] != '' ): @@ -86,7 +86,5 @@ class screen(): environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) - else: - environment['screenData']['newNegativeDelta'] = '' - environment['screenData']['newDelta'] = '' + return environment From 875640c5c171bb7b43d2824b27782671a5177891 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 23:16:11 +0200 Subject: [PATCH 3/5] redu wrong fix --- src/fenrir-package/screen/linux.py | 37 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index 32cb9fa9..2eb38dd9 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -65,26 +65,31 @@ class screen(): environment['screenData']['oldCursor']['y'] = 0 environment['screenData']['oldDelta'] = '' environment['screenData']['oldNegativeDelta'] = '' - # always clear deltas + # always clear current deltas environment['screenData']['newNegativeDelta'] = '' - environment['screenData']['newDelta'] = '' + environment['screenData']['newDelta'] = '' # changes on the screen if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ (environment['screenData']['newContentText'] != '' ): - diffStart = 0 - if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ - environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ - environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: - diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] - diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ - environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) + if environment['screenData']['oldContentText'] == '' and\ + environment['screenData']['newContentText'] != '': + environment['screenData']['newDelta'] = environment['screenData']['newContentText'] else: - diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ - environment['screenData']['newContentText'][diffStart:].split('\n')) - - diffList = list(diff) + diffStart = 0 + if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ + environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ + environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: + diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] + diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ + environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) + else: + diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ + environment['screenData']['newContentText'][diffStart:].split('\n')) + + diffList = list(diff) + + environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) + environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) - environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) - environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) - return environment + From 18b9e92b1910cd72a746ad99ed39687643e5a889 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 23:20:27 +0200 Subject: [PATCH 4/5] try to fix delete trigger --- .../commands/onScreenChanged/65000-char_delete_echo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py b/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py index 0e909c90..dfa308e0 100644 --- a/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py +++ b/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py @@ -24,7 +24,9 @@ class command(): # No deletion if environment['screenData']['newNegativeDelta'] == '': return environment - + # too much for a single backspace... + if len(environment['screenData']['newNegativeDelta']) >= 5: + return environment environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newNegativeDelta'], interrupt=True) return environment def setCallback(self, callback): From 50c21547e4775bfd984f7860521bb8929f740158 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 23:39:12 +0200 Subject: [PATCH 5/5] update ToDo --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index 98b36831..fc46fdb1 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ ToDos in Priority order: - Known Bugs - sometimes the screen is spoken from the beginning without need to gstreamer sounddriver doesnt work - try to consume shortcuts