Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
105 changes: 88 additions & 17 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: UTF-8 -*-
#globalCommands.py
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2006-2018 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka
# A part of NonVisual Desktop Access (NVDA)
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.
# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
# Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka

import time
import itertools
Expand Down Expand Up @@ -1391,6 +1391,8 @@ def script_sayAll(self,gesture):
def _reportFormattingHelper(self, info, browseable=False):
# Report all formatting-related changes regardless of user settings
# when explicitly requested.
if info is None:
return
# These are the options we want reported when reporting formatting manually.
# for full list of options that may be reported see the "documentFormatting" section of L{config.configSpec}
reportFormattingOptions = (
Expand Down Expand Up @@ -1463,16 +1465,87 @@ def _reportFormattingHelper(self, info, browseable=False):
_("Formatting")
)

def script_reportFormatting(self,gesture):
info=api.getReviewPosition()
repeats=scriptHandler.getLastScriptRepeatCount()
if repeats==0:
self._reportFormattingHelper(info,False)
elif repeats==1:
self._reportFormattingHelper(info,True)
# Translators: Input help mode message for report formatting command.
script_reportFormatting.__doc__ = _("Reports formatting info for the current review cursor position within a document. If pressed twice, presents the information in browse mode")
script_reportFormatting.category=SCRCAT_TEXTREVIEW
def _getTIAtCaret(self):
# Returns text info at the caret position if there is a caret in the current control, None othervise.
# Note that if there is no caret this fact is announced in speech and braille.
obj = api.getFocusObject()
treeInterceptor = obj.treeInterceptor
if(
isinstance(treeInterceptor, treeInterceptorHandler.DocumentTreeInterceptor)
and not treeInterceptor.passThrough
):
obj = treeInterceptor
try:
info = obj.makeTextInfo(textInfos.POSITION_CARET)
return info
except (NotImplementedError, RuntimeError):
# Translators: Reported when there is no caret.
ui.message(_("No caret"))
return

@script(
# Translators: Input help mode message for report formatting command.
description=_("Reports formatting info for the current review cursor position."),
category=SCRCAT_TEXTREVIEW,
)
def script_reportFormattingAtReview(self, gesture):
self._reportFormattingHelper(api.getReviewPosition(), False)

@script(
# Translators: Input help mode message for show formatting at review cursor command.
description=_("Presents, in browse mode, formatting info for the current review cursor position."),
category=SCRCAT_TEXTREVIEW,
)
def script_showFormattingAtReview(self, gesture):
self._reportFormattingHelper(api.getReviewPosition(), True)

@script(
description=_(
# Translators: Input help mode message for report formatting command.
"Reports formatting info for the current review cursor position."
" If pressed twice, presents the information in browse mode"
),
category=SCRCAT_TEXTREVIEW,
gesture="kb:NVDA+shift+f",
)
def script_reportFormatting(self, gesture):
repeats = scriptHandler.getLastScriptRepeatCount()
if repeats == 0:
self.script_reportFormattingAtReview(gesture)
elif repeats == 1:
self.script_showFormattingAtReview(gesture)

@script(
# Translators: Input help mode message for report formatting at caret command.
description=_("Reports formatting info for the text under the caret."),
category=SCRCAT_SYSTEMCARET,
)
def script_reportFormattingAtCaret(self, gesture):
self._reportFormattingHelper(self._getTIAtCaret(), False)

@script(
# Translators: Input help mode message for show formatting at caret position command.
description=_("Presents, in browse mode, formatting info for the text under the caret."),
category=SCRCAT_SYSTEMCARET,
)
def script_showFormattingAtCaret(self, gesture):
self._reportFormattingHelper(self._getTIAtCaret(), True)

@script(
description=_(
# Translators: Input help mode message for report formatting at caret command.
"Reports formatting info for the thext under the caret."
" If pressed twice, presents the information in browse mode"
),
category=SCRCAT_SYSTEMCARET,
gesture="kb:NVDA+f",
)
def script_reportOrShowFormattingAtCaret(self, gesture):
repeats = scriptHandler.getLastScriptRepeatCount()
if repeats == 0:
self.script_reportFormattingAtCaret(gesture)
elif repeats == 1:
self.script_showFormattingAtCaret(gesture)

def script_reportCurrentFocus(self,gesture):
focusObject=api.getFocusObject()
Expand Down Expand Up @@ -2625,8 +2698,6 @@ def _enableScreenCurtain(doEnable: bool = True):
"kb(laptop):NVDA+l": "reportCurrentLine",
"kb(desktop):NVDA+shift+upArrow": "reportCurrentSelection",
"kb(laptop):NVDA+shift+s": "reportCurrentSelection",
"kb:NVDA+f": "reportFormatting",

# Object navigation
"kb:NVDA+numpad5": "navigatorObject_current",
"kb(laptop):NVDA+shift+o": "navigatorObject_current",
Expand Down
3 changes: 2 additions & 1 deletion user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ NVDA provides the following key commands in relation to the system caret:
| Say all | NVDA+downArrow | NVDA+a | Starts reading from the current position of the system caret, moving it along as it goes |
| Read current line | NVDA+upArrow | NVDA+l | Reads the line where the system caret is currently situated. Pressing twice spells the line. Pressing three times spells the line using character descriptions. |
| Read current text selection | NVDA+Shift+upArrow | NVDA+shift+s | Reads any currently selected text |
| Report text formatting | NVDA+f | NVDA+f | Reports the formatting of the text where the caret is currently situated. Pressing twice shows the information in browse mode |
| Next sentence | alt+downArrow | alt+downArrow | Moves the caret to the next sentence and announces it. (only supported in Microsoft Word and Outlook) |
| Previous sentence | alt+upArrow | alt+upArrow | Moves the caret to the previous sentence and announces it. (only supported in Microsoft Word and Outlook) |

Expand Down Expand Up @@ -413,7 +414,7 @@ The following commands are available for reviewing text:
| Select then Copy from review cursor | NVDA+f9 | NVDA+f9 | none | Starts the select then copy process from the current position of the review cursor. The actual action is not performed until you tell NVDA where the end of the text range is |
| Select then Copy to review cursor | NVDA+f10 | NVDA+f10 | none | On the first press, text is selected from the position previously set as start marker up to and including the review cursor's current position. If the system carret can reach the text, it will be moved to the selected text. After pressing this key stroke a second time, the text will be copied to the Windows clipboard |
| Move to marked start for copy in review | NVDA+shift+f9 | NVDA+shift+f9 | none | Moves the review cursor to the position previously set start marker for copy |
| Report text formatting | NVDA+f | NVDA+f | none | Reports the formatting of the text where the review cursor is currently situated. Pressing twice shows the information in browse mode |
| Report text formatting | NVDA+shift+f | NVDA+shift+f | none | Reports the formatting of the text where the review cursor is currently situated. Pressing twice shows the information in browse mode |
| Report current symbol replacement | None | None | none | Speaks the symbol where the review cursor is positioned. Pressed twice, shows the symbol and the text used to speak it in browse mode. |
%kc:endInclude

Expand Down