Skip to content

Commit 2274421

Browse files
authored
Merge 5d9b8cc into 3f89b60
2 parents 3f89b60 + 5d9b8cc commit 2274421

5 files changed

Lines changed: 46 additions & 4 deletions

File tree

source/config/configSpec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
reportLineNumber = boolean(default=False)
213213
# 0: Off, 1: Speech, 2: Tones, 3: Both Speech and Tones
214214
reportLineIndentation = integer(0, 3, default=0)
215+
ignoreBlankLinesForReportLineIndentation = boolean(default=False)^M
215216
reportParagraphIndentation = boolean(default=False)
216217
reportTables = boolean(default=true)
217218
includeLayoutTables = boolean(default=False)

source/globalCommands.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def script_reportCurrentSelection(self,gesture):
273273
speech.speakMessage(_("No selection"))
274274
else:
275275
speech.speakTextSelected(info.text)
276-
276+
277277
@script(
278278
# Translators: Input help mode message for report date and time command.
279279
description=_("If pressed once, reports the current time. If pressed twice, reports the current date"),
@@ -622,6 +622,21 @@ def script_toggleReportLineIndentation(self, gesture: inputCore.InputGesture):
622622
# {mode} will be replaced with the mode; i.e. Off, Speech, Tones or Both Speech and Tones.
623623
ui.message(_("Report line indentation {mode}").format(mode=state.displayString))
624624

625+
@script(
626+
# Translators: Input help mode message for toggle ignore blank lines for line indentation reporting command.
627+
description=_("Toggles on and off the ignoring of blank lines for line indentation reporting"),
628+
category=SCRCAT_DOCUMENTFORMATTING
629+
)
630+
def script_toggleignoreBlankLinesForReportLineIndentation(self,gesture: inputCore.InputGesture) -> None:
631+
ignore = config.conf['documentFormatting']['ignoreBlankLinesForReportLineIndentation']
632+
config.conf['documentFormatting']['ignoreBlankLinesForReportLineIndentation'] = not ignore
633+
if ignore:
634+
# Translators: The message announced when toggling off the ignore blank lines for line indentation reporting document formatting setting.
635+
ui.message(_("Ignore blank lines for line indentation reporting off"))
636+
else:
637+
# Translators: The message announced when toggling on the ignore blank lines for line indentation reporting document formatting setting.
638+
ui.message(_("Ignore blank lines for line indentation reporting on"))
639+
625640
@script(
626641
# Translators: Input help mode message for toggle report paragraph indentation command.
627642
description=_("Toggles on and off the reporting of paragraph indentation"),

source/gui/settingsDialogs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,15 +2389,22 @@ def makeSettings(self, settingsSizer):
23892389
self.lineIndentationCombo
23902390
)
23912391
self.lineIndentationCombo.SetSelection(config.conf['documentFormatting']['reportLineIndentation'])
2392+
2393+
# Translators: This is the label of a checkbox in the document formatting settings panel
2394+
# If this option is selected, NVDA will ignore blank lines for line indentation reporting
2395+
ignoreBlankLinesText = _("Ignore &blank lines for line indentation reporting")
2396+
ignoreBlankLinesCheckBox = wx.CheckBox(pageAndSpaceBox, label=ignoreBlankLinesText)
2397+
self.ignoreBlankLinesForReportLineIndentationCheckbox = pageAndSpaceGroup.addItem(ignoreBlankLinesCheckBox)
2398+
self.ignoreBlankLinesForReportLineIndentationCheckbox.SetValue(config.conf["documentFormatting"]["ignoreBlankLinesForReportLineIndentation"])
23922399

2393-
# Translators: This message is presented in the document formatting settings panelue
2400+
# Translators: This message is presented in the document formatting settings panel
23942401
# If this option is selected, NVDA will report paragraph indentation if available.
23952402
paragraphIndentationText = _("&Paragraph indentation")
23962403
_paragraphIndentationCheckBox = wx.CheckBox(pageAndSpaceBox, label=paragraphIndentationText)
23972404
self.paragraphIndentationCheckBox = pageAndSpaceGroup.addItem(_paragraphIndentationCheckBox)
23982405
self.paragraphIndentationCheckBox.SetValue(config.conf["documentFormatting"]["reportParagraphIndentation"])
23992406

2400-
# Translators: This message is presented in the document formatting settings panelue
2407+
# Translators: This message is presented in the document formatting settings panel
24012408
# If this option is selected, NVDA will report line spacing if available.
24022409
lineSpacingText=_("&Line spacing")
24032410
_lineSpacingCheckBox = wx.CheckBox(pageAndSpaceBox, label=lineSpacingText)
@@ -2541,6 +2548,7 @@ def onSave(self):
25412548
config.conf["documentFormatting"]["reportPage"]=self.pageCheckBox.IsChecked()
25422549
config.conf["documentFormatting"]["reportLineNumber"]=self.lineNumberCheckBox.IsChecked()
25432550
config.conf["documentFormatting"]["reportLineIndentation"] = self.lineIndentationCombo.GetSelection()
2551+
config.conf["documentFormatting"]["ignoreBlankLinesForReportLineIndentation"]=self.ignoreBlankLinesForReportLineIndentationCheckbox.IsChecked()
25442552
config.conf["documentFormatting"]["reportParagraphIndentation"]=self.paragraphIndentationCheckBox.IsChecked()
25452553
config.conf["documentFormatting"]["reportLineSpacing"]=self.lineSpacingCheckBox.IsChecked()
25462554
config.conf["documentFormatting"]["reportTables"]=self.tablesCheckBox.IsChecked()

source/speech/speech.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,17 @@ def getTextInfoSpeech( # noqa: C901
15401540
if autoLanguageSwitching and newLanguage!=lastLanguage:
15411541
relativeSpeechSequence.append(LangChangeCommand(newLanguage))
15421542
lastLanguage=newLanguage
1543-
if reportIndentation and speakTextInfoState and allIndentation!=speakTextInfoState.indentationCache:
1543+
if (
1544+
reportIndentation
1545+
and speakTextInfoState
1546+
and(
1547+
# either not ignoring blank lines
1548+
not formatConfig['ignoreBlankLinesForReportLineIndentation']
1549+
# or line isn't completely blank
1550+
or any(isinstance(t, str) and not all(c in LINE_END_CHARS for c in t) for t in textWithFields)
1551+
)
1552+
and allIndentation!=speakTextInfoState.indentationCache
1553+
):
15441554
indentationSpeech=getIndentationSpeech(allIndentation, formatConfig)
15451555
if autoLanguageSwitching and speechSequence[-1].lang is not None:
15461556
# Indentation must be spoken in the default language,
@@ -1604,6 +1614,10 @@ def getTextInfoSpeech( # noqa: C901
16041614
return True
16051615

16061616

1617+
# for checking a line is completely blank, i.e. doesn't even contain spaces
1618+
LINE_END_CHARS = frozenset(( '\r', '\n' ))
1619+
1620+
16071621
def _isControlEndFieldCommand(command: Union[str, textInfos.FieldCommand]):
16081622
return isinstance(command, textInfos.FieldCommand) and command.command == "controlEnd"
16091623

user_docs/en/userGuide.t2t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,7 @@ You can configure reporting of:
20762076
- Page numbers
20772077
- Line numbers
20782078
- Line indentation reporting [(Off, Speech, Tones, Both Speech and Tones) #DocumentFormattingSettingsLineIndentation]
2079+
- Ignore blank lines for line indentation reporting
20792080
- Paragraph indentation (e.g. hanging indent, first line indent)
20802081
- Line spacing (single, double, etc.)
20812082
- Alignment
@@ -2118,6 +2119,9 @@ The tone will increase in pitch every space, and for a tab, it will increase in
21182119
- Both Speech and Tones: This option reads indentation using both of the above methods.
21192120
-
21202121

2122+
If you tick the "Ignore blank lines for line indentation reporting" checkbox, then indentation changes won't be reported for blank lines.
2123+
This may be useful when reading a document where blank lines are used to separate indented bloks of text, such as in programming source code.
2124+
21212125
+++ Document Navigation +++[DocumentNavigation]
21222126
This category allows you to adjust various aspects of document navigation.
21232127

0 commit comments

Comments
 (0)