Skip to content

Commit c97f0ff

Browse files
authored
Merge fe587dd into 9967903
2 parents 9967903 + fe587dd commit c97f0ff

2 files changed

Lines changed: 90 additions & 18 deletions

File tree

source/globalCommands.py

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: UTF-8 -*-
2-
#globalCommands.py
3-
#A part of NonVisual Desktop Access (NVDA)
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
6-
#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
2+
# A part of NonVisual Desktop Access (NVDA)
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
5+
# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
6+
# Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka
77

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

1466-
def script_reportFormatting(self,gesture):
1467-
info=api.getReviewPosition()
1468-
repeats=scriptHandler.getLastScriptRepeatCount()
1469-
if repeats==0:
1470-
self._reportFormattingHelper(info,False)
1471-
elif repeats==1:
1472-
self._reportFormattingHelper(info,True)
1473-
# Translators: Input help mode message for report formatting command.
1474-
script_reportFormatting.__doc__ = _("Reports formatting info for the current review cursor position within a document. If pressed twice, presents the information in browse mode")
1475-
script_reportFormatting.category=SCRCAT_TEXTREVIEW
1468+
def _getTIAtCaret(self):
1469+
# Returns text info at the caret position if there is a caret in the current control, None othervise.
1470+
# Note that if there is no caret this fact is announced in speech and braille.
1471+
obj = api.getFocusObject()
1472+
treeInterceptor = obj.treeInterceptor
1473+
if(
1474+
isinstance(treeInterceptor, treeInterceptorHandler.DocumentTreeInterceptor)
1475+
and not treeInterceptor.passThrough
1476+
):
1477+
obj = treeInterceptor
1478+
try:
1479+
info = obj.makeTextInfo(textInfos.POSITION_CARET)
1480+
return info
1481+
except (NotImplementedError, RuntimeError):
1482+
# Translators: Reported when there is no caret.
1483+
ui.message(_("No caret"))
1484+
return
1485+
1486+
@script(
1487+
# Translators: Input help mode message for report formatting command.
1488+
description=_("Reports formatting info for the current review cursor position."),
1489+
category=SCRCAT_TEXTREVIEW,
1490+
)
1491+
def script_reportFormattingAtReview(self, gesture):
1492+
self._reportFormattingHelper(api.getReviewPosition(), False)
1493+
1494+
@script(
1495+
# Translators: Input help mode message for show formatting at review cursor command.
1496+
description=_("Presents, in browse mode, formatting info for the current review cursor position."),
1497+
category=SCRCAT_TEXTREVIEW,
1498+
)
1499+
def script_showFormattingAtReview(self, gesture):
1500+
self._reportFormattingHelper(api.getReviewPosition(), True)
1501+
1502+
@script(
1503+
# Translators: Input help mode message for report formatting command.
1504+
description=_(
1505+
"""Reports formatting info for the current review cursor position.
1506+
If pressed twice, presents the information in browse mode"""
1507+
),
1508+
category=SCRCAT_TEXTREVIEW,
1509+
gesture="kb:NVDA+shift+f",
1510+
)
1511+
def script_reportFormatting(self, gesture):
1512+
repeats = scriptHandler.getLastScriptRepeatCount()
1513+
if repeats == 0:
1514+
self.script_reportFormattingAtReview(gesture)
1515+
elif repeats == 1:
1516+
self.script_showFormattingAtReview(gesture)
1517+
1518+
@script(
1519+
# Translators: Input help mode message for report formatting at caret command.
1520+
description=_("Reports formatting info for the text under the caret."),
1521+
category=SCRCAT_SYSTEMCARET,
1522+
)
1523+
def script_reportFormattingAtCaret(self, gesture):
1524+
self._reportFormattingHelper(self._getTIAtCaret(), False)
1525+
1526+
@script(
1527+
# Translators: Input help mode message for show formatting at caret position command.
1528+
description=_("Presents, in browse mode, formatting info for the text under the caret."),
1529+
category=SCRCAT_SYSTEMCARET,
1530+
)
1531+
def script_showFormattingAtCaret(self, gesture):
1532+
self._reportFormattingHelper(self._getTIAtCaret(), True)
1533+
1534+
@script(
1535+
# Translators: Input help mode message for report formatting at caret command.
1536+
description=_(
1537+
"""Reports formatting info for the thext under the caret.
1538+
If pressed twice, presents the information in browse mode"""
1539+
),
1540+
category=SCRCAT_SYSTEMCARET,
1541+
gesture="kb:NVDA+f",
1542+
)
1543+
def script_reportOrShowFormattingAtCaret(self, gesture):
1544+
repeats = scriptHandler.getLastScriptRepeatCount()
1545+
if repeats == 0:
1546+
self.script_reportFormattingAtCaret(gesture)
1547+
elif repeats == 1:
1548+
self.script_showFormattingAtCaret(gesture)
14761549

14771550
def script_reportCurrentFocus(self,gesture):
14781551
focusObject=api.getFocusObject()
@@ -2625,8 +2698,6 @@ def _enableScreenCurtain(doEnable: bool = True):
26252698
"kb(laptop):NVDA+l": "reportCurrentLine",
26262699
"kb(desktop):NVDA+shift+upArrow": "reportCurrentSelection",
26272700
"kb(laptop):NVDA+shift+s": "reportCurrentSelection",
2628-
"kb:NVDA+f": "reportFormatting",
2629-
26302701
# Object navigation
26312702
"kb:NVDA+numpad5": "navigatorObject_current",
26322703
"kb(laptop):NVDA+shift+o": "navigatorObject_current",

user_docs/en/userGuide.t2t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ NVDA provides the following key commands in relation to the system caret:
328328
| Say all | NVDA+downArrow | NVDA+a | Starts reading from the current position of the system caret, moving it along as it goes |
329329
| 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. |
330330
| Read current text selection | NVDA+Shift+upArrow | NVDA+shift+s | Reads any currently selected text |
331+
| 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 |
331332
| Next sentence | alt+downArrow | alt+downArrow | Moves the caret to the next sentence and announces it. (only supported in Microsoft Word and Outlook) |
332333
| Previous sentence | alt+upArrow | alt+upArrow | Moves the caret to the previous sentence and announces it. (only supported in Microsoft Word and Outlook) |
333334

@@ -413,7 +414,7 @@ The following commands are available for reviewing text:
413414
| 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 |
414415
| 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 |
415416
| 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 |
416-
| 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 |
417+
| 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 |
417418
| 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. |
418419
%kc:endInclude
419420

0 commit comments

Comments
 (0)