From 81fda2a9706c22d13ad5c8378b319deeb19e21e3 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Tue, 11 Jul 2023 22:54:49 +0300 Subject: [PATCH 1/5] update braille when tethered to review but review does not follow caret --- source/review.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/review.py b/source/review.py index 538160f55e2..6a31d6f602d 100644 --- a/source/review.py +++ b/source/review.py @@ -1,5 +1,5 @@ # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2013-2022 NV Access Limited +# Copyright (C) 2013-2023 NV Access Limited, Burman's Computer and Education Ltd. # This file may be used under the terms of the GNU General Public License, version 2 or later. # For more details see: https://www.gnu.org/licenses/gpl-2.0.html @@ -10,14 +10,19 @@ import api from baseObject import ScriptableObject +import braille import winUser from logHandler import log from NVDAObjects import NVDAObject, NVDAObjectTextInfo from NVDAObjects.window import Window -from treeInterceptorHandler import DocumentTreeInterceptor +from treeInterceptorHandler import ( + DocumentTreeInterceptor, + TreeInterceptor, +) from displayModel import DisplayModelTextInfo import textInfos import config +from config.configFlags import TetherTo def getObjectPosition(obj): """ @@ -152,13 +157,20 @@ def nextMode(prev=False,startMode=None): label=setCurrentMode(newMode) return label or nextMode(prev=prev,startMode=newMode) -def handleCaretMove(pos): + +def handleCaretMove(pos: Union[textInfos.TextInfo, NVDAObject, TreeInterceptor]) -> None: """ Instructs the review position to be updated due to caret movement. - @param pos: Either a TextInfo instance at the caret position, or an NVDAObject or TeeInterceptor who's caret position should be retreaved. + Note: When braille is explicitly tethered to review, and review cursor + does not follow system caret, braille display is however updated + if content of current navigator object changes. + @param pos: Either a TextInfo instance at the caret position, + or an NVDAObject or TreeInterceptor who's caret position should be retrieved. @type pos: L{textInfos.TextInfo} or L{NVDAObject} or L{TreeInterceptor} """ if not config.conf["reviewCursor"]["followCaret"]: + if config.conf["braille"]["tetherTo"] == TetherTo.REVIEW.value: + braille.handler.handleUpdate(api.getNavigatorObject()) return if isinstance(pos,textInfos.TextInfo): info=pos From 2afd12c70e9b4a63f5dde510516e878b470ae86f Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 12 Jul 2023 10:52:00 +0300 Subject: [PATCH 2/5] minor modifications --- source/review.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/review.py b/source/review.py index 6a31d6f602d..d0d9bcd627e 100644 --- a/source/review.py +++ b/source/review.py @@ -162,15 +162,20 @@ def handleCaretMove(pos: Union[textInfos.TextInfo, NVDAObject, TreeInterceptor]) """ Instructs the review position to be updated due to caret movement. Note: When braille is explicitly tethered to review, and review cursor - does not follow system caret, braille display is however updated - if content of current navigator object changes. + does not follow system caret, braille display is however updated if: + + - navigator object is focus object or its ancestor and + - content of navigator object changes. + @param pos: Either a TextInfo instance at the caret position, or an NVDAObject or TreeInterceptor who's caret position should be retrieved. @type pos: L{textInfos.TextInfo} or L{NVDAObject} or L{TreeInterceptor} """ if not config.conf["reviewCursor"]["followCaret"]: if config.conf["braille"]["tetherTo"] == TetherTo.REVIEW.value: - braille.handler.handleUpdate(api.getNavigatorObject()) + navigatorObject: NVDAObject = api.getNavigatorObject() + if navigatorObject == api.getFocusObject() or navigatorObject in api.getFocusAncestors(): + braille.handler.handleUpdate(navigatorObject) return if isinstance(pos,textInfos.TextInfo): info=pos From 5bb11ece00f1fb97a3309fc05cef2e5ad3bc0183 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 12 Jul 2023 19:02:33 +0300 Subject: [PATCH 3/5] logic moved to braille module --- source/braille.py | 10 ++++++++++ source/review.py | 25 ++++--------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/source/braille.py b/source/braille.py index aaeba83bbf5..c95354c9b4c 100644 --- a/source/braille.py +++ b/source/braille.py @@ -2468,6 +2468,16 @@ def handleCaretMove( if shouldAutoTether: self.setTether(TetherTo.FOCUS.value, auto=True) if self._tether != TetherTo.FOCUS.value: + # However, braille display content is updated in case where: + # braille is tethered to review, review cursor does not follow system caret, + # and navigator object is focus object or its ancestor. + if ( + not config.conf["reviewCursor"]["followCaret"] + and config.conf["braille"]["tetherTo"] == TetherTo.REVIEW.value + ): + navigatorObject: NVDAObject = api.getNavigatorObject() + if navigatorObject == api.getFocusObject() or navigatorObject in api.getFocusAncestors(): + self.handleUpdate(navigatorObject) return region = self.mainBuffer.regions[-1] if self.mainBuffer.regions else None if region and region.obj==obj: diff --git a/source/review.py b/source/review.py index d0d9bcd627e..538160f55e2 100644 --- a/source/review.py +++ b/source/review.py @@ -1,5 +1,5 @@ # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2013-2023 NV Access Limited, Burman's Computer and Education Ltd. +# Copyright (C) 2013-2022 NV Access Limited # This file may be used under the terms of the GNU General Public License, version 2 or later. # For more details see: https://www.gnu.org/licenses/gpl-2.0.html @@ -10,19 +10,14 @@ import api from baseObject import ScriptableObject -import braille import winUser from logHandler import log from NVDAObjects import NVDAObject, NVDAObjectTextInfo from NVDAObjects.window import Window -from treeInterceptorHandler import ( - DocumentTreeInterceptor, - TreeInterceptor, -) +from treeInterceptorHandler import DocumentTreeInterceptor from displayModel import DisplayModelTextInfo import textInfos import config -from config.configFlags import TetherTo def getObjectPosition(obj): """ @@ -157,25 +152,13 @@ def nextMode(prev=False,startMode=None): label=setCurrentMode(newMode) return label or nextMode(prev=prev,startMode=newMode) - -def handleCaretMove(pos: Union[textInfos.TextInfo, NVDAObject, TreeInterceptor]) -> None: +def handleCaretMove(pos): """ Instructs the review position to be updated due to caret movement. - Note: When braille is explicitly tethered to review, and review cursor - does not follow system caret, braille display is however updated if: - - - navigator object is focus object or its ancestor and - - content of navigator object changes. - - @param pos: Either a TextInfo instance at the caret position, - or an NVDAObject or TreeInterceptor who's caret position should be retrieved. + @param pos: Either a TextInfo instance at the caret position, or an NVDAObject or TeeInterceptor who's caret position should be retreaved. @type pos: L{textInfos.TextInfo} or L{NVDAObject} or L{TreeInterceptor} """ if not config.conf["reviewCursor"]["followCaret"]: - if config.conf["braille"]["tetherTo"] == TetherTo.REVIEW.value: - navigatorObject: NVDAObject = api.getNavigatorObject() - if navigatorObject == api.getFocusObject() or navigatorObject in api.getFocusAncestors(): - braille.handler.handleUpdate(navigatorObject) return if isinstance(pos,textInfos.TextInfo): info=pos From 23b6698b09140b62b40487bf5f2a0842623e0829 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 12 Jul 2023 19:06:22 +0300 Subject: [PATCH 4/5] indentation fix --- source/braille.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/braille.py b/source/braille.py index c95354c9b4c..8d8984c0ee5 100644 --- a/source/braille.py +++ b/source/braille.py @@ -2469,7 +2469,7 @@ def handleCaretMove( self.setTether(TetherTo.FOCUS.value, auto=True) if self._tether != TetherTo.FOCUS.value: # However, braille display content is updated in case where: - # braille is tethered to review, review cursor does not follow system caret, + # braille is tethered to review, review cursor does not follow system caret, # and navigator object is focus object or its ancestor. if ( not config.conf["reviewCursor"]["followCaret"] From 81dcab0ee630d4a5972dc6cfbd73e84e34bc7003 Mon Sep 17 00:00:00 2001 From: burmancomp Date: Wed, 12 Jul 2023 19:56:24 +0300 Subject: [PATCH 5/5] suggested changes --- source/braille.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/braille.py b/source/braille.py index 8d8984c0ee5..68884e24338 100644 --- a/source/braille.py +++ b/source/braille.py @@ -2468,16 +2468,12 @@ def handleCaretMove( if shouldAutoTether: self.setTether(TetherTo.FOCUS.value, auto=True) if self._tether != TetherTo.FOCUS.value: - # However, braille display content is updated in case where: + # Braille display content is updated in case where: # braille is tethered to review, review cursor does not follow system caret, - # and navigator object is focus object or its ancestor. - if ( - not config.conf["reviewCursor"]["followCaret"] - and config.conf["braille"]["tetherTo"] == TetherTo.REVIEW.value - ): - navigatorObject: NVDAObject = api.getNavigatorObject() - if navigatorObject == api.getFocusObject() or navigatorObject in api.getFocusAncestors(): - self.handleUpdate(navigatorObject) + # and focus object is navigator object. + if not config.conf["reviewCursor"]["followCaret"]: + if obj == api.getNavigatorObject(): + self.handleUpdate(obj) return region = self.mainBuffer.regions[-1] if self.mainBuffer.regions else None if region and region.obj==obj: