Skip to content

Commit

Permalink
This is now controlled by two text boxes.
Browse files Browse the repository at this point in the history
This no longer beeps with speech mode off. re nvaccess#5906 @jcsteh I haven't had time to update the user guide yet, I'll let you know when that's complete.
  • Loading branch information
derekriemer committed Jun 17, 2016
1 parent b899f9c commit 6111c4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 36 deletions.
3 changes: 1 addition & 2 deletions source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ def validateConfig(configObj,validator,validationResult=None,keyList=None):
reportPage = boolean(default=true)
reportLineNumber = boolean(default=False)
reportLineIndentation = boolean(default=False)
#INDENT_SPEECH is speech, INDENT_TONE is tones, | them to get the correct setting.
indentType =integer(min=1, default=1)
reportToneIndentation = boolean(default=False)
reportParagraphIndentation = boolean(default=False)
reportTables = boolean(default=true)
includeLayoutTables = boolean(default=False)
Expand Down
32 changes: 6 additions & 26 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,31 +1113,14 @@ def makeSettings(self, settingsSizer):
settingsSizer.Add(self.lineNumberCheckBox,border=10,flag=wx.BOTTOM)
# Translators: This message is presented in the document formatting settings dialogue
# If this option is selected, NVDA will cound the leading spaces and tabs of a line and speak it.
#
self.lineIndentationCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report l&ine indentation"))
self.lineIndentationCheckBox.SetValue(config.conf["documentFormatting"]["reportLineIndentation"])
self.lineIndentationCheckBox.Bind(wx.EVT_CHECKBOX,self.onReportIndentChange)
settingsSizer.Add(self.lineIndentationCheckBox,border=10,flag=wx.BOTTOM)
sizer=wx.BoxSizer(wx.HORIZONTAL)
# Translators: This is the label for a combobox in the
# Document Formatting dialog (possible choices are Speech, Tones, or Both.
sizer.Add(wx.StaticText(self,wx.ID_ANY,label=_("Report &Indents With:")))
indentChoices=[
#Translators: A setting to report indents with Speech.
_("Speech"),
#Translators: A setting to report indents with tones.
_("Tones"),
#Translators: A setting to report indents with both tones and Speech.
_("Both Tones and Speech")
]
self.indentTypeList=wx.Choice(self,wx.ID_ANY,choices=indentChoices)
curChoice = config.conf["documentFormatting"]["indentType"]
self.indentTypeList.SetSelection(curChoice-1) #Choices are 1-3, but we need 0-2.
sizer.Add(self.indentTypeList)
settingsSizer.Add(sizer)
if not config.conf["documentFormatting"]["reportLineIndentation"]:
self.indentTypeList.Enable(False)

# Translators: This message is presented in the document formatting settings dialogue
# If this option is selected, NVDA will cound the leading spaces and tabs of a line and play a tone to report it.
self.toneIndentationCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report l&ine indentation with tones"))
self.toneIndentationCheckBox.SetValue(config.conf["documentFormatting"]["reportToneIndentation"])
settingsSizer.Add(self.toneIndentationCheckBox,border=10,flag=wx.BOTTOM)
# Translators: This message is presented in the document formatting settings dialogue
# If this option is selected, NVDA will report paragraph indentation if available.
self.paragraphIndentationCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &paragraph indentation"))
Expand Down Expand Up @@ -1197,9 +1180,6 @@ def makeSettings(self, settingsSizer):
def postInit(self):
self.detectFormatAfterCursorCheckBox.SetFocus()

def onReportIndentChange(self, evt):
self.indentTypeList.Enable(self.lineIndentationCheckBox.GetValue())

def onOk(self,evt):
config.conf["documentFormatting"]["detectFormatAfterCursor"]=self.detectFormatAfterCursorCheckBox.IsChecked()
config.conf["documentFormatting"]["reportFontName"]=self.fontNameCheckBox.IsChecked()
Expand All @@ -1215,7 +1195,7 @@ def onOk(self,evt):
config.conf["documentFormatting"]["reportPage"]=self.pageCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineNumber"]=self.lineNumberCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineIndentation"]=self.lineIndentationCheckBox.IsChecked()
config.conf["documentFormatting"]["indentType"] = self.indentTypeList.GetSelection()+1
config.conf["documentFormatting"]["reportToneIndentation"]=self.toneIndentationCheckBox.IsChecked()
config.conf["documentFormatting"]["reportParagraphIndentation"]=self.paragraphIndentationCheckBox.IsChecked()
config.conf["documentFormatting"]["reportTables"]=self.tablesCheckBox.IsChecked()
config.conf["documentFormatting"]["reportTableHeaders"]=self.tableHeadersCheckBox.IsChecked()
Expand Down
15 changes: 7 additions & 8 deletions source/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,20 @@ def splitTextIndentation(text):
IDT_BASE_FREQUENCY = 220 #One octave below middle A.
IDT_TONE_DURATION = 80 #Milleseconds
IDT_MAX_SPACES = 72
INDENT_SPEECH = 1
INDENT_TONES = 2
def getIndentationSpeech(indentation):
"""Retrieves the phrase to be spoken for a given string of indentation.
@param indentation: The string of indentation.
@type indentation: unicode
@return: The phrase to be spoken.
@rtype: unicode
"""
indentConfig = config.conf["documentFormatting"]["indentType"]
speechIndentConfig = config.conf["documentFormatting"]["reportLineIndentation"]
toneIndentConfig = config.conf["documentFormatting"]["reportToneIndentation"] and speechMode == speechMode_talk
if not indentation:
if indentConfig & INDENT_TONES:
if toneIndentConfig:
tones.beep(IDT_BASE_FREQUENCY, IDT_TONE_DURATION)
# Translators: This is spoken when the given line has no indentation.
return (_("no indent") if indentConfig & INDENT_SPEECH else "")
return (_("no indent") if speechIndentConfig else "")

#The non-breaking space is semantically a space, so we replace it here.
indentation = indentation.replace(u"\xa0", u" ")
Expand All @@ -445,8 +444,8 @@ def getIndentationSpeech(indentation):
res.append(u"{count} {symbol}".format(count=count, symbol=symbol))
quarterTones += (count*4 if raw[0]== "\t" else count)

speak = indentConfig & INDENT_SPEECH
if indentConfig & INDENT_TONES:
speak = speechIndentConfig
if toneIndentConfig:
if quarterTones <= IDT_MAX_SPACES:
#Remove me during speech refactor.
pitch = IDT_BASE_FREQUENCY*2**(quarterTones/24.0) #24 quarter tones per octave.
Expand Down Expand Up @@ -683,7 +682,7 @@ def speakTextInfo(info,useCache=True,formatConfig=None,unit=None,reason=controlT
if extraDetail:
formatConfig=formatConfig.copy()
formatConfig['extraDetail']=True
reportIndentation=unit==textInfos.UNIT_LINE and formatConfig["reportLineIndentation"]
reportIndentation=unit==textInfos.UNIT_LINE and ( formatConfig["reportLineIndentation"] or formatConfig["reportToneIndentation"])

speechSequence=[]
#Fetch the last controlFieldStack, or make a blank one
Expand Down

0 comments on commit 6111c4a

Please sign in to comment.