def sayCharacter(self, obj): """Speak the character at the caret. Arguments: - obj: an Accessible object that implements the AccessibleText interface """ boundary = pyatspi.TEXT_BOUNDARY_CHAR objects = self.utilities.getObjectsFromEOCs(obj, boundary) for (obj, start, end, string) in objects: if string: speech.speakCharacter(string) else: speech.speak(self.speechGenerator.generateSpeech(obj))
def onTextDeleted(self, event): """Called whenever text is deleted from an object. Arguments: - event: the Event """ event_string, mods = self.utilities.lastKeyAndModifiers() # We only do special things when people press backspace # in terminals. # if (event.source.getRole() != pyatspi.ROLE_TERMINAL) \ or (event_string != "BackSpace"): gtk.Script.onTextDeleted(self, event) return # Ignore text deletions from non-focused objects, unless the # currently focused object is the parent of the object from which # text was deleted. # if (event.source != orca_state.locusOfFocus) \ and (event.source.parent != orca_state.locusOfFocus): return self.updateBraille(event.source) # Speak the character that has just been deleted. # character = event.any_data if character.isupper(): voice = self.voices[settings.UPPERCASE_VOICE] else: voice = self.voices[settings.DEFAULT_VOICE] if len(character) == 1: speech.speakCharacter(character, voice) else: speech.speak(character, voice, False)
def sayWord(self, obj): """Speaks the word at the caret. Overridden here because we seem to be getting the details of the word we just left when moving forward with Control Right Arrow. Control Left Arrow works as expected with the default script with the exception of crossing over a blank line (which sometimes causes the word with focus to be repeated). Both problems are addressed here. Arguments: - obj: an Accessible object that implements the AccessibleText interface """ if not (obj.parent.getRole() in [pyatspi.ROLE_DRAWING_AREA, pyatspi.ROLE_UNKNOWN]): default.Script.sayWord(self, obj) else: text = obj.queryText() offset = text.caretOffset lastKey, mods = self.utilities.lastKeyAndModifiers() if lastKey == "Right": penultimateWord = orca_state.lastWord [lastWord, startOffset, endOffset] = \ text.getTextAtOffset(offset, pyatspi.TEXT_BOUNDARY_WORD_START) [word, startOffset, endOffset] = \ text.getTextAfterOffset(endOffset+1, pyatspi.TEXT_BOUNDARY_WORD_START) if len(penultimateWord) > 0: lastCharPW = penultimateWord[len(penultimateWord) - 1] if lastCharPW == "\n": voice = self.voices[settings.DEFAULT_VOICE] speech.speakCharacter("\n", voice) if penultimateWord != lastWord: word = lastWord if lastKey == "Left": lastWord = orca_state.lastWord [word, startOffset, endOffset] = \ text.getTextAtOffset(offset, pyatspi.TEXT_BOUNDARY_WORD_START) if len(word) > 0: lastChar = word[len(word) - 1] if lastChar == "\n" and lastWord != word: voice = self.voices[settings.DEFAULT_VOICE] speech.speakCharacter("\n", voice) if lastWord == word: return if self.utilities.linkIndex(obj, offset) >= 0: voice = self.voices[settings.HYPERLINK_VOICE] elif word.decode("UTF-8").isupper(): voice = self.voices[settings.UPPERCASE_VOICE] else: voice = self.voices[settings.DEFAULT_VOICE] word = self.utilities.adjustForRepeats(word) orca_state.lastWord = word speech.speak(word, voice) self.speakTextSelectionState(obj, startOffset, endOffset)