|
1 |
| -#cursorManager.py |
2 |
| -#A part of NonVisual Desktop Access (NVDA) |
3 |
| -#Copyright (C) 2006-2018 NV Access Limited, Joseph Lee, Derek Riemer, Davy Kager |
4 |
| -#This file is covered by the GNU General Public License. |
5 |
| -#See the file COPYING for more details. |
| 1 | +# A part of NonVisual Desktop Access (NVDA) |
| 2 | +# Copyright (C) 2006-2022 NV Access Limited, Joseph Lee, Derek Riemer, Davy Kager, Rob Meredith |
| 3 | +# This file is covered by the GNU General Public License. |
| 4 | +# See the file COPYING for more details. |
6 | 5 |
|
7 | 6 | """
|
8 | 7 | Implementation of cursor managers.
|
|
26 | 25 | import braille
|
27 | 26 | import vision
|
28 | 27 | import controlTypes
|
29 |
| -from inputCore import SCRCAT_BROWSEMODE |
| 28 | +from inputCore import ( |
| 29 | + SCRCAT_BROWSEMODE, |
| 30 | + InputGesture, |
| 31 | +) |
30 | 32 | import ui
|
31 | 33 | from textInfos import DocumentWithPageTurns
|
| 34 | +from logHandler import log |
32 | 35 |
|
33 | 36 |
|
34 | 37 | class FindDialog(
|
@@ -264,12 +267,35 @@ def script_moveBySentence_forward(self,gesture):
|
264 | 267 | self._caretMovementScriptHelper(gesture,textInfos.UNIT_SENTENCE,1)
|
265 | 268 | script_moveBySentence_forward.resumeSayAllMode = sayAll.CURSOR.CARET
|
266 | 269 |
|
267 |
| - def script_moveByParagraph_back(self,gesture): |
268 |
| - self._caretMovementScriptHelper(gesture,textInfos.UNIT_PARAGRAPH,-1) |
| 270 | + def _handleParagraphNavigation(self, gesture: InputGesture, nextParagraph: bool) -> None: |
| 271 | + from config.featureFlagEnums import ParagraphNavigationFlag |
| 272 | + flag: config.featureFlag.FeatureFlag = config.conf["documentNavigation"]["paragraphStyle"] |
| 273 | + if ( |
| 274 | + flag.calculated() == ParagraphNavigationFlag.APPLICATION |
| 275 | + or flag.calculated() == ParagraphNavigationFlag.SINGLE_LINE_BREAK |
| 276 | + ): |
| 277 | + self._caretMovementScriptHelper(gesture, textInfos.UNIT_PARAGRAPH, 1 if nextParagraph else -1) |
| 278 | + elif flag.calculated() == ParagraphNavigationFlag.MULTI_LINE_BREAK: |
| 279 | + from documentNavigation.paragraphHelper import moveToMultiLineBreakParagraph |
| 280 | + ti = self.makeTextInfo(textInfos.POSITION_SELECTION) |
| 281 | + passKey, moved = moveToMultiLineBreakParagraph( |
| 282 | + nextParagraph=nextParagraph, |
| 283 | + speakNew=not willSayAllResume(gesture), |
| 284 | + ti=ti) |
| 285 | + if moved: |
| 286 | + self.selection = ti |
| 287 | + elif passKey: |
| 288 | + # fail over to default behavior |
| 289 | + self._caretMovementScriptHelper(gesture, textInfos.UNIT_PARAGRAPH, 1 if nextParagraph else -1) |
| 290 | + else: |
| 291 | + log.error(f"Unexpected ParagraphNavigationFlag value {flag.value}") |
| 292 | + |
| 293 | + def script_moveByParagraph_back(self, gesture: InputGesture): |
| 294 | + self._handleParagraphNavigation(gesture, False) |
269 | 295 | script_moveByParagraph_back.resumeSayAllMode = sayAll.CURSOR.CARET
|
270 | 296 |
|
271 |
| - def script_moveByParagraph_forward(self,gesture): |
272 |
| - self._caretMovementScriptHelper(gesture,textInfos.UNIT_PARAGRAPH,1) |
| 297 | + def script_moveByParagraph_forward(self, gesture: InputGesture): |
| 298 | + self._handleParagraphNavigation(gesture, True) |
273 | 299 | script_moveByParagraph_forward.resumeSayAllMode = sayAll.CURSOR.CARET
|
274 | 300 |
|
275 | 301 | def script_startOfLine(self,gesture):
|
|
0 commit comments