Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify success of forward review moves by word and line #12960

Merged
merged 5 commits into from
Oct 21, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,18 +1324,23 @@ def script_review_currentLine(self,gesture):
category=SCRCAT_TEXTREVIEW,
gestures=("kb:numpad9", "kb(laptop):NVDA+downArrow", "ts(text):flickDown")
)
def script_review_nextLine(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_LINE)
info.collapse()
res=info.move(textInfos.UNIT_LINE,1)
if res==0:
def script_review_nextLine(self, gesture):
origInfo = api.getReviewPosition().copy()
origInfo.collapse()
info = origInfo.copy()
res = info.move(textInfos.UNIT_LINE, 1)
newLine = info.copy()
newLine.expand(textInfos.UNIT_LINE)
# #12808: Some implementations of move forward by one line may succeed one more time than expected,
# Landing on the exclusive end of the document.
# Therefore, verify that expanding after the move does result in being on a new line,
# I.e. the new line starts after the original review cursor position.
codeofdusk marked this conversation as resolved.
Show resolved Hide resolved
if res == 0 or newLine.start <= origInfo.start:
# Translators: a message reported when review cursor is at the bottom line of the current navigator object.
ui.reviewMessage(_("Bottom"))
else:
api.setReviewPosition(info)
info.expand(textInfos.UNIT_LINE)
speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=controlTypes.OutputReason.CARET)
speech.speakTextInfo(newLine, unit=textInfos.UNIT_LINE, reason=controlTypes.OutputReason.CARET)

@script(
# Translators: Input help mode message for move review cursor to bottom line command.
Expand Down Expand Up @@ -1395,18 +1400,23 @@ def script_review_currentWord(self,gesture):
category=SCRCAT_TEXTREVIEW,
gestures=("kb:numpad6", "kb(laptop):NVDA+control+rightArrow", "ts(text):2finger_flickRight")
)
def script_review_nextWord(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_WORD)
info.collapse()
res=info.move(textInfos.UNIT_WORD,1)
if res==0:
def script_review_nextWord(self, gesture):
origInfo = api.getReviewPosition().copy()
origInfo.collapse()
info = origInfo.copy()
res = info.move(textInfos.UNIT_WORD, 1)
newWord = info.copy()
newWord.expand(textInfos.UNIT_WORD)
# #12808: Some implementations of move forward by one word may succeed one more time than expected,
# Landing on the exclusive end of the document.
# Therefore, verify that expanding after the move does result in being on a new word,
# I.e. the new word starts after the original review cursor position.
codeofdusk marked this conversation as resolved.
Show resolved Hide resolved
if res == 0 or newWord.start <= origInfo.start:
# Translators: a message reported when review cursor is at the bottom line of the current navigator object.
ui.reviewMessage(_("Bottom"))
else:
api.setReviewPosition(info)
info.expand(textInfos.UNIT_WORD)
speech.speakTextInfo(info, reason=controlTypes.OutputReason.CARET, unit=textInfos.UNIT_WORD)
speech.speakTextInfo(newWord, unit=textInfos.UNIT_WORD, reason=controlTypes.OutputReason.CARET)

@script(
description=_(
Expand Down