Skip to content

Commit

Permalink
Merge branch 'i5906' into next
Browse files Browse the repository at this point in the history
Re #6057.
  • Loading branch information
jcsteh committed Jun 10, 2016
2 parents f3206a4 + 088aa58 commit 5859154
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
2 changes: 2 additions & 0 deletions source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ 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)
reportParagraphIndentation = boolean(default=False)
reportTables = boolean(default=true)
includeLayoutTables = boolean(default=False)
Expand Down
25 changes: 25 additions & 0 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,28 @@ def makeSettings(self, settingsSizer):
#
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 report paragraph indentation if available.
self.paragraphIndentationCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &paragraph indentation"))
Expand Down Expand Up @@ -1176,6 +1197,9 @@ 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 @@ -1190,6 +1214,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"]["reportParagraphIndentation"]=self.paragraphIndentationCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineSpacing"]=self.lineSpacingCheckBox.IsChecked()
config.conf["documentFormatting"]["reportTables"]=self.tablesCheckBox.IsChecked()
Expand Down
25 changes: 21 additions & 4 deletions source/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,23 +408,30 @@ def splitTextIndentation(text):
return RE_INDENTATION_SPLIT.match(text).groups()

RE_INDENTATION_CONVERT = re.compile(r"(?P<char>\s)(?P=char)*", re.UNICODE)
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
"""
# Translators: no indent is spoken when the user moves from a line that has indentation, to one that
# does not.
indentConfig = config.conf["documentFormatting"]["indentType"]
if not indentation:
if indentConfig & INDENT_TONES:
tones.beep(IDT_BASE_FREQUENCY, IDT_TONE_DURATION)
# Translators: This is spoken when the given line has no indentation.
return _("no indent")

#The non-breaking space is semantically a space, so we replace it here.
indentation = indentation.replace(u"\xa0", u" ")
res = []
locale=languageHandler.getLanguage()
quarterTones = 0
for m in RE_INDENTATION_CONVERT.finditer(indentation):
raw = m.group()
symbol = characterProcessing.processSpeechSymbol(locale, raw[0])
Expand All @@ -436,8 +443,18 @@ def getIndentationSpeech(indentation):
res.append(symbol)
else:
res.append(u"{count} {symbol}".format(count=count, symbol=symbol))

return " ".join(res)
quarterTones += (count*4 if raw[0]== "\t" else count)

speak = indentConfig & INDENT_SPEECH
if indentConfig & INDENT_TONES:
if quarterTones <= IDT_MAX_SPACES:
#Remove me during speech refactor.
pitch = IDT_BASE_FREQUENCY*2**(quarterTones/24.0) #24 quarter tones per octave.
tones.beep(pitch, IDT_TONE_DURATION)
else:
#we have more than 72 spaces (18 tabs), and must speak it since we don't want to hurt the users ears.
speak = True
return (" ".join(res) if speak else "")

def speak(speechSequence,symbolLevel=None):
"""Speaks a sequence of text and speech commands
Expand Down
9 changes: 9 additions & 0 deletions user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,15 @@ By default, NVDA will detect the formatting at the position of the System caret

Enable this option while proof reading documents in applications such as Microsoft Word, where formatting is important.

==== Report indents as ====
When Report Line Indentation is enabled, the Report indents as combo box has three options.

- Speech: If speech is selected, when the level of indented text changes, NVDA will say something like "twelve space" or "four tab."
- Tones: If Tones is selected, when the level of indented text changes, tones indicate the amount of change in indent.
The tone will increase in pitch every space, and for a tab, it will increase in pitch the equivalent of 4 spaces.
- Both Speech and Tones: This option reads indents using both of the above methods.
-

+++ Speech dictionaries +++
The speech dictionaries menu (found in the Preferences menu) contains dialogs that allow you to manage the way NVDA pronounces particular words or phrases.
There are currently three different types of speech dictionaries.
Expand Down

0 comments on commit 5859154

Please sign in to comment.