def _caretScriptPostMovedHelper(self, speakUnit, gesture, info = None): """ This method ensures that LaTeX translation occurs when the system caret moves, and also makes sure that normal behaviour occurs when l{processMaths} is off. """ if isScriptWaiting (): return if not info: try: info = self.makeTextInfo (textInfos.POSITION_CARET) except: return review.handleCaretMove(info) if speakUnit == textInfos.UNIT_LINE and EditableText.processMaths and not willSayAllResume(gesture): spokenLine = GetLine () brailledLine = GetLine () if not spokenLine and not brailledLine:# Is it a blank line? spokenLine = _("blank") brailledLine = _("") else: spokenLine = EditableText.latex_access.speech (spokenLine) brailledLine = EditableText.latex_access.nemeth (brailledLine) speech.speakMessage (spokenLine) braille.handler.message (brailledLine) else: if speakUnit and not willSayAllResume(gesture): info.expand(speakUnit) speech.speakTextInfo(info, unit=speakUnit, reason=controlTypes.REASON_CARET) braille.handler.handleCaretMove(self)
def move(self, gesture, regex, increment, errorMsg): focus = api.getFocusObject() if not getConfig("enableInWord") and ( isinstance(focus, winword.WordDocument) or ("Dynamic_IAccessibleRichEdit" in str(type(focus)) and hasattr(focus, "script_caret_nextSentence") and hasattr(focus, "script_caret_previousSentence"))): if increment > 0: focus.script_caret_nextSentence(gesture) elif increment < 0: focus.script_caret_previousSentence(gesture) else: # increment == 0 pass return if focus.role in [ controlTypes.ROLE_COMBOBOX, controlTypes.ROLE_LISTITEM, controlTypes.ROLE_BUTTON ]: try: # The following line will only succeed in BrowserMode. focus.treeInterceptor.script_collapseOrExpandControl(gesture) except AttributeError: gesture.send() return if hasattr(focus, "treeInterceptor") and hasattr( focus.treeInterceptor, "makeTextInfo"): focus = focus.treeInterceptor try: caretInfo = focus.makeTextInfo(textInfos.POSITION_CARET) except NotImplementedError: gesture.send() return caretIndex, paragraphInfo = getCaretIndexWithinParagraph(caretInfo) context = Context(paragraphInfo, caretIndex, caretInfo) reconstructMode = getConfig("reconstructMode") sentenceStr, ti = self.moveExtended(context, increment, regex=regex, errorMsg=errorMsg, reconstructMode=reconstructMode) if ti is None: return if increment != 0: newCaret = ti.copy() newCaret.collapse() newCaret.updateCaret() review.handleCaretMove(newCaret) braille.handler.handleCaretMove(focus) vision.handler.handleCaretMove(focus) if willSayAllResume(gesture): return if getConfig("speakFormatted"): speech.speakTextInfo(ti, reason=REASON_CARET) else: speech.speakText(sentenceStr)
def moveToBookmark(position): obj = api.getFocusObject() treeInterceptor=obj.treeInterceptor if isinstance(treeInterceptor, BrowseModeDocumentTreeInterceptor) and not treeInterceptor.passThrough: obj = treeInterceptor bookmark = Offsets(position, position) info = obj.makeTextInfo(bookmark) info.updateSelection() review.handleCaretMove(info) speech.cancelSpeech() info.move(textInfos.UNIT_LINE,1,endPoint="end") speech.speakTextInfo(info,reason=controlTypes.REASON_CARET)
def _caretScriptPostMovedHelper(self, speakUnit, gesture, info=None): if isScriptWaiting(): return if not info: try: info = self.makeTextInfo(textInfos.POSITION_CARET) except: return review.handleCaretMove(info) if speakUnit and not willSayAllResume(gesture): info.expand(speakUnit) speech.speakTextInfo(info, unit=speakUnit, reason=controlTypes.REASON_CARET) braille.handler.handleCaretMove(self)
def _caretScriptPostMovedHelper(self, speakUnit, gesture, info=None): if isScriptWaiting() or eventHandler.isPendingEvents("gainFocus"): return if not info: try: info = self.makeTextInfo(textInfos.POSITION_CARET) except: return # Forget the word currently being typed as the user has moved the caret somewhere else. speech.clearTypedWordBuffer() review.handleCaretMove(info) if speakUnit and not willSayAllResume(gesture): info.expand(speakUnit) speech.speakTextInfo(info, unit=speakUnit, reason=controlTypes.REASON_CARET) braille.handler.handleCaretMove(self)
def _jumpTo(self, posToJump): if self.ti.obj is None: # When the object for which the textInfo passed to the dialog loses focus # it's no longer valid therefore jumping, even after dialog closes, fails. # Since creating the TI from scratch is vastefull use this work around. self.ti.obj = api.getFocusObject() if hasattr(self, "getFixedValue"): posToJump = self.getFixedValue(posToJump) try: speech.cancelSpeech() self.ti.move(self.movingUnit, int(posToJump), "start") self.ti.updateCaret() self.ti.expand(textInfos.UNIT_LINE) review.handleCaretMove(self.ti) speech.speakTextInfo(self.ti, unit=textInfos.UNIT_LINE, reason=controlTypes.REASON_CARET) except NotImplementedError: pass
def _caretScriptPostMovedHelper(self, speakUnit, gesture, info=None): if isScriptWaiting(): return if not info: try: info = self.makeTextInfo(textInfos.POSITION_CARET) except: return review.handleCaretMove(info) if speakUnit and not willSayAllResume(gesture): info2 = info.copy() info.expand(speakUnit) if speakUnit == textInfos.UNIT_LINE and mode == 'start': info.setEndPoint(info2, "endToEnd") elif speakUnit == textInfos.UNIT_LINE and mode == 'end': info.setEndPoint(info2, "startToStart") speech.speakTextInfo(info, unit=speakUnit, reason=controlTypes.REASON_CARET) braille.handler.handleCaretMove(self)
def _caretMoveBySentenceHelper(self, gesture, direction): if isScriptWaiting(): return if not self.WinwordSelectionObject: # Legacy object model not available. # Translators: a message when navigating by sentence is unavailable in MS Word ui.message( _("Navigating by sentence not supported in this document")) gesture.send() return # Using the legacy object model, # Move the caret to the next sentence in the requested direction. legacyInfo = LegacyWordDocumentTextInfo(self, textInfos.POSITION_CARET) legacyInfo.move(textInfos.UNIT_SENTENCE, direction) # Save the start of the sentence for future use legacyStart = legacyInfo.copy() # With the legacy object model, # Move the caret to the end of the new sentence. legacyInfo.move(textInfos.UNIT_SENTENCE, 1) legacyInfo.updateCaret() # Fetch the caret position (end of the next sentence) with UI automation. endInfo = self.makeTextInfo(textInfos.POSITION_CARET) # Move the caret back to the start of the next sentence, # where it should be left for the user. legacyStart.updateCaret() # Fetch the new caret position (start of the next sentence) with UI Automation. startInfo = self.makeTextInfo(textInfos.POSITION_CARET) # Make a UI automation text range spanning the entire next sentence. info = startInfo.copy() info.end = endInfo.end # Speak the sentence moved to speech.speakTextInfo(info, unit=textInfos.UNIT_SENTENCE, reason=controlTypes.OutputReason.CARET) # Forget the word currently being typed as the user has moved the caret somewhere else. speech.clearTypedWordBuffer() # Alert review and braille the caret has moved to its new position review.handleCaretMove(info) braille.handler.handleCaretMove(self)
def script_selectPreviousBookmark(self, gesture): obj = api.getFocusObject() appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True) if appName == "MicrosoftEdgeCP.exe": gesture.send() return treeInterceptor=obj.treeInterceptor if isinstance(treeInterceptor, BrowseModeDocumentTreeInterceptor) and not treeInterceptor.passThrough: obj=treeInterceptor else: gesture.send() return bookmarks = getSavedBookmarks() if bookmarks == {}: ui.message( # Translators: message presented when trying to select a bookmark, but none is found. _("No bookmarks found")) return curPos = obj.makeTextInfo(textInfos.POSITION_CARET).bookmark.startOffset prevPos = None for pos in sorted(bookmarks, reverse=True): if pos < curPos: prevPos = pos break if prevPos is not None: info = obj.makeTextInfo(Offsets(prevPos, prevPos)) info.updateSelection() review.handleCaretMove(info) if willSayAllResume(gesture): info.move(textInfos.UNIT_LINE,1,endPoint="end") #speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) else: ui.message( # Translators: message presented when a bookmark is selected. _("Position: character %d") % prevPos) return ui.message( # Translators: message presented when the previous bookmark is not found. _("Previous bookmark not found"))
def _set_selection(self, info): info.updateSelection() review.handleCaretMove(info) braille.handler.handleCaretMove(self) vision.handler.handleCaretMove(self)
def event_caret(self): if self is api.getFocusObject() and not eventHandler.isPendingEvents("gainFocus"): braille.handler.handleCaretMove(self) brailleInput.handler.handleCaretMove(self) review.handleCaretMove(self)
def event_caret(self, obj, nextHandler): self.detectPossibleSelectionChange() braille.handler.handleCaretMove(self) caret = self.makeTextInfo(textInfos.POSITION_CARET) review.handleCaretMove(caret)
def event_caret(self): if self is api.getFocusObject() and not eventHandler.isPendingEvents("gainFocus"): braille.handler.handleCaretMove(self) review.handleCaretMove(self)
def _set_selection(self, info): info.updateSelection() review.handleCaretMove(info) braille.handler.handleCaretMove(self)