Skip to content

Commit 85bf451

Browse files
authored
Merge e28d007 into 23b4992
2 parents 23b4992 + e28d007 commit 85bf451

4 files changed

Lines changed: 28 additions & 1 deletion

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/gui/settingsDialogs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,6 +2389,13 @@ 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

23932400
# Translators: This message is presented in the document formatting settings panelue
23942401
# If this option is selected, NVDA will report paragraph indentation if available.
@@ -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 identically 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)