Skip to content

Commit

Permalink
Merge branch 't4185' into next. Incubates #4185
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelDCurran committed Jun 11, 2014
2 parents ea45818 + 38eac48 commit d09e413
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
2 changes: 2 additions & 0 deletions source/NVDAObjects/behaviors.py
Expand Up @@ -191,6 +191,8 @@ class LiveText(NVDAObject):
# If the text is live, this is definitely content.
presentationType = NVDAObject.presType_content

announceNewLineText=False

def initOverlayClass(self):
self._event = threading.Event()
self._monitorThread = None
Expand Down
1 change: 1 addition & 0 deletions source/NVDAObjects/window/winword.py
Expand Up @@ -440,6 +440,7 @@ def setEndPoint(self,other,which):
elif which=="startToEnd":
self._rangeObj.Start=other._rangeObj.End
elif which=="endToStart":
print "start %s, end %s, otherStart %s, otherEnd %s"%(self._rangeObj.start,self._rangeObj.end,other._rangeObj.start,other._rangeObj.end)
self._rangeObj.End=other._rangeObj.Start
elif which=="endToEnd":
self._rangeObj.End=other._rangeObj.End
Expand Down
29 changes: 29 additions & 0 deletions source/editableText.py
Expand Up @@ -39,6 +39,9 @@ class EditableText(ScriptableObject):
#: Whether to fire caretMovementFailed events when the caret doesn't move in response to a caret movement key.
shouldFireCaretMovementFailedEvents = False

#: Whether or not to announce text found before the caret on a new line (e.g. auto numbering)
announceNewLineText=True

def _hasCaretMoved(self, bookmark, retryInterval=0.01, timeout=0.03):
"""
Waits for the caret to move, for a timeout to elapse, or for a new focus event or script to be queued.
Expand Down Expand Up @@ -99,6 +102,31 @@ def _caretMovementScriptHelper(self, gesture, unit):
eventHandler.executeEvent("caretMovementFailed", self, gesture=gesture)
self._caretScriptPostMovedHelper(unit,gesture,newInfo)

def script_enter(self,gesture):
if not self.announceNewLineText:
gesture.send()
return
try:
info=self.makeTextInfo(textInfos.POSITION_CARET)
except:
gesture.send()
return
bookmark=info.bookmark
gesture.send()
caretMoved,newInfo=self._hasCaretMoved(bookmark)
if not caretMoved:
return
newInfo=self.makeTextInfo(textInfos.POSITION_CARET)
lineInfo=self.makeTextInfo(textInfos.POSITION_CARET)
lineInfo.expand(textInfos.UNIT_LINE)
lineInfo.setEndPoint(newInfo,"endToStart")
if lineInfo.isCollapsed:
lineInfo.expand(textInfos.UNIT_CHARACTER)
onlyInitial=True
else:
onlyInitial=False
speech.speakTextInfo(lineInfo,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET,onlyInitialFields=onlyInitial)

def script_caret_moveByLine(self,gesture):
self._caretMovementScriptHelper(gesture, textInfos.UNIT_LINE)
script_caret_moveByLine.resumeSayAllMode=sayAllHandler.CURSOR_CARET
Expand Down Expand Up @@ -158,6 +186,7 @@ def script_caret_delete(self,gesture):
braille.handler.handleCaretMove(self)

__gestures = {
"kb:enter":"enter",
"kb:upArrow": "caret_moveByLine",
"kb:downArrow": "caret_moveByLine",
"kb:leftArrow": "caret_moveByCharacter",
Expand Down
9 changes: 5 additions & 4 deletions source/speech.py
Expand Up @@ -586,7 +586,7 @@ def updateObj(self):
def copy(self):
return self.__class__(self)

def speakTextInfo(info,useCache=True,formatConfig=None,unit=None,reason=controlTypes.REASON_QUERY,index=None):
def speakTextInfo(info,useCache=True,formatConfig=None,unit=None,reason=controlTypes.REASON_QUERY,index=None,onlyInitialFields=False):
if isinstance(useCache,SpeakTextInfoState):
speakTextInfoState=useCache
elif useCache:
Expand Down Expand Up @@ -703,10 +703,11 @@ def speakTextInfo(info,useCache=True,formatConfig=None,unit=None,reason=controlT
speechSequence.append(LangChangeCommand(language))
lastLanguage=language

if unit in (textInfos.UNIT_CHARACTER,textInfos.UNIT_WORD) and len(textWithFields)>0 and len(textWithFields[0])==1 and all((isinstance(x,textInfos.FieldCommand) and x.command=="controlEnd") for x in itertools.islice(textWithFields,1,None) ):
if any(isinstance(x,basestring) for x in speechSequence):
if onlyInitialFields or (unit in (textInfos.UNIT_CHARACTER,textInfos.UNIT_WORD) and len(textWithFields)>0 and len(textWithFields[0])==1 and all((isinstance(x,textInfos.FieldCommand) and x.command=="controlEnd") for x in itertools.islice(textWithFields,1,None) )):
if onlyInitialFields or any(isinstance(x,basestring) for x in speechSequence):
speak(speechSequence)
speakSpelling(textWithFields[0],locale=language if autoLanguageSwitching else None)
if not onlyInitialFields:
speakSpelling(textWithFields[0],locale=language if autoLanguageSwitching else None)
if useCache:
speakTextInfoState.controlFieldStackCache=newControlFieldStack
speakTextInfoState.formatFieldAttributesCache=formatFieldAttributesCache
Expand Down
4 changes: 4 additions & 0 deletions user_docs/en/changes.t2t
Expand Up @@ -5,6 +5,10 @@

= 2014.3 =

== Changes ==
- Updated liblouis braille translator to 2.5.4. (#4103)


== Bug Fixes ==
- In Google Chrome and Chrome-based browsers, certain chunks of text (such as those with emphasis) are no longer repeated when reporting the text of an alert or dialog. (#4066)
- In browse mode in Mozilla applications, pressing enter on a button, etc. no longer fails to activate it (or activates the wrong control) in certain cases such as the buttons at the top of Facebook. (#4106)
Expand Down

0 comments on commit d09e413

Please sign in to comment.