def script_reportCurrentLine (self, gesture):
		"""
		This script reports the line that the current navigator object is focused on, and speaks/brailles it appropriately depending on the state of l{processMaths}.  If pressed twice quickly, the current line is spelt out.
		@param gesture: the gesture to be passed through to NVDA (in this case, a keypress).
		@type gesture: l{inputCore.InputGesture}.
		"""
		#obj is an alias for self. to ease maintenence in Inherited code.
		obj = self
		treeInterceptor=obj.treeInterceptor
		if hasattr(treeInterceptor,'TextInfo') and not treeInterceptor.passThrough:
			obj=treeInterceptor
		try:
			info=obj.makeTextInfo(textInfos.POSITION_CARET)
		except (NotImplementedError, RuntimeError):
			info=obj.makeTextInfo(textInfos.POSITION_FIRST)
		info.expand(textInfos.UNIT_LINE)
		if scriptHandler.getLastScriptRepeatCount()==0:
			if EditableLatex.processMaths:
				spokenLine = GetLine ()
				if not spokenLine:# Is it a blank line?
					spokenLine = _("blank")
				else:
					self.speakMathLine(spokenLine)
			else:
				speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET)
		else:
			speech.speakSpelling(info.text)
Example #2
0
 def _backspaceScriptHelper(self, unit, gesture):
     try:
         oldInfo = self.makeTextInfo(textInfos.POSITION_CARET)
     except:
         gesture.send()
         return
     oldBookmark = oldInfo.bookmark
     testInfo = oldInfo.copy()
     res = testInfo.move(textInfos.UNIT_CHARACTER, -1)
     if res < 0:
         testInfo.expand(unit)
         delChunk = testInfo.text
     else:
         delChunk = ""
     gesture.send()
     caretMoved, newInfo = self._hasCaretMoved(oldBookmark)
     if not caretMoved:
         return
     delChunk = delChunk.replace(
         "\r\n", "\n")  # Occurs with at least with Scintilla
     if len(delChunk) > 1:
         speech.speakMessage(delChunk)
     else:
         speech.speakSpelling(delChunk)
     self._caretScriptPostMovedHelper(None, gesture, newInfo)
	def script_navigatorObject_current(self,gesture):
		curObject=api.getNavigatorObject()
		if not isinstance(curObject,NVDAObject):
			speech.speakMessage(_("no navigator object"))
			return
		if scriptHandler.getLastScriptRepeatCount()>=1:
			if curObject.TextInfo!=NVDAObjectTextInfo:
				textList=[]
				if curObject.name and isinstance(curObject.name, basestring) and not curObject.name.isspace():
					textList.append(curObject.name)
				try:
					info=curObject.makeTextInfo(textInfos.POSITION_SELECTION)
					if not info.isCollapsed:
						textList.append(info.text)
					else:
						info.expand(textInfos.UNIT_LINE)
						if not info.isCollapsed:
							textList.append(info.text)
				except (RuntimeError, NotImplementedError):
					# No caret or selection on this object.
					pass
			else:
				textList=[prop for prop in (curObject.name, curObject.value) if prop and isinstance(prop, basestring) and not prop.isspace()]
			text=" ".join(textList)
			if len(text)>0 and not text.isspace():
				if scriptHandler.getLastScriptRepeatCount()==1:
					speech.speakSpelling(text)
				else:
					if api.copyToClip(text):
						speech.speakMessage(_("%s copied to clipboard")%text)
		else:
			speech.speakObject(curObject,reason=speech.REASON_QUERY)
	def script_reportStatusLine(self, gesture):
		#it seems that the status bar is the last child of the forground object
		#so, get it from there
		obj = api.getForegroundObject().lastChild
		found=False
		if obj and obj.role == controlTypes.ROLE_STATUSBAR:
			text = api.getStatusBarText(obj)
			api.setNavigatorObject(obj)
			found=True
		else:
			info=api.getForegroundObject().flatReviewPosition
			if info:
				info.expand(textInfos.UNIT_STORY)
				info.collapse(True)
				info.expand(textInfos.UNIT_LINE)
				text=info.text
				info.collapse()
				api.setReviewPosition(info)
				found=True
		if not found:
			# Translators: Reported when there is no status line for the current program or window.
			ui.message(_("No status line found"))
			return
		if scriptHandler.getLastScriptRepeatCount()==0:
			ui.message(text)
		else:
			speech.speakSpelling(text)
	def event_typedCharacter(self, ch):
		#default implementation of typedCharacter causes VS and NVDA to crash badly, if the user hits esc while in the quick watch window
		#the direct reason for the problem is that NVDA tries to get the states for the object to decide whether typing is protected, and it seams the object will be already destroied in that stage
		#only speek typed characters if needed
		if config.conf["keyboard"]["speakTypedCharacters"] and ord(ch)>=32:
			speech.speakSpelling(ch)
		return
Example #6
0
 def script_announceAudioPosition(self, gesture):
     audioPosition = self.getTime(self._getByVersion('audio'))
     repeatCount = scriptHandler.getLastScriptRepeatCount()
     if repeatCount == 0:
         ui.message(audioPosition)
     elif repeatCount == 1:
         speech.speakSpelling(audioPosition)
Example #7
0
	def script_reportCurrentLine (self, gesture):
		"""
		This script reports the line that the current navigator object is focused on, and speaks/brailles it appropriately depending on the state of l{processMaths}.  If pressed twice quickly, the current line is spelt out.
		@param gesture: the gesture to be passed through to NVDA (in this case, a keypress).
		@type gesture: l{inputCore.InputGesture}.
		"""

		obj=api.getFocusObject()
		treeInterceptor=obj.treeInterceptor
		if hasattr(treeInterceptor,'TextInfo') and not treeInterceptor.passThrough:
			obj=treeInterceptor
		try:
			info=obj.makeTextInfo(textInfos.POSITION_CARET)
		except (NotImplementedError, RuntimeError):
			info=obj.makeTextInfo(textInfos.POSITION_FIRST)
		info.expand(textInfos.UNIT_LINE)
		if getLastScriptRepeatCount()==0:
			if EditableText.processMaths:
				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:
				speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET)
		else:
			speech.speakSpelling(info.text)
	def script_review_currentWord(self,gesture):
		info=api.getReviewPosition().copy()
		info.expand(textInfos.UNIT_WORD)
		scriptCount=scriptHandler.getLastScriptRepeatCount()
		if scriptCount==0:
			speech.speakTextInfo(info,reason=speech.REASON_CARET,unit=textInfos.UNIT_WORD)
		else:
			speech.speakSpelling(info.text,useCharacterDescriptions=bool(scriptCount>1))
	def script_reportCurrentFocus(self,gesture):
		focusObject=api.getFocusObject()
		if isinstance(focusObject,NVDAObject):
			if scriptHandler.getLastScriptRepeatCount()==0:
				speech.speakObject(focusObject, reason=speech.REASON_QUERY)
			else:
				speech.speakSpelling(focusObject.name)
		else:
			speech.speakMessage(_("no focus"))
Example #10
0
 def script_title(self, gesture):
     title = self.pageTitle
     repeatCount = scriptHandler.getLastScriptRepeatCount()
     if repeatCount == 0:
         ui.message(title)
     elif repeatCount == 1:
         speech.speakSpelling(title)
     else:
         if api.copyToClip(title):
             ui.message(_("%s copied to clipboard") % title)
Example #11
0
 def callback(repeatCount):
     self.taskTimer = None
     obj = findWindowNVDAObject("buffer")
     if obj is None or not self.inMainWindow():
         return
     text = obj.windowText
     if repeatCount:
         speakSpelling(text[text.find(":") + 1:].strip())
     else:
         ui.message(text)
	def script_reportStatusLine(self,gesture):
		obj = api.getStatusBar()
		if not obj:
			ui.message(_("no status bar found"))
			return
		text = api.getStatusBarText(obj)

		if scriptHandler.getLastScriptRepeatCount()==0:
			ui.message(text)
		else:
			speech.speakSpelling(text)
		api.setNavigatorObject(obj)
Example #13
0
	def reportFocus(self):
		speech.speakObjectProperties(self,name=True,role=True)
		info=self.makeTextInfo(textInfos.POSITION_CARET)
		info.move(textInfos.UNIT_WORD,-1,endPoint="start")
		try:
			error=info._rangeObj.spellingErrors[1].text
		except:
			info.expand(textInfos.UNIT_STORY)
			speech.speakText(info.text)
			return
		speech.speakText(error)
		speech.speakSpelling(error)
Example #14
0
	def poll(self, *args, **kwargs):
		self.pollTimer = None
		oldWord = self.previousWord or ""
		newWord = self.word or ""
		if newWord != oldWord:
			self.previousWord = newWord
			if len(newWord) > len(oldWord) and newWord[:len(oldWord)] == oldWord:
				speech.speakSpelling(newWord[len(oldWord):])
			elif newWord:
				speech.speakText(newWord)
				speech.speakSpelling(newWord)
			elif oldWord:
				speech.speakText("cleared")
		self.schedulePoll()
	def script_reportCurrentLine(self,gesture):
		obj=api.getFocusObject()
		treeInterceptor=obj.treeInterceptor
		if hasattr(treeInterceptor,'TextInfo') and not treeInterceptor.passThrough:
			obj=treeInterceptor
		try:
			info=obj.makeTextInfo(textInfos.POSITION_CARET)
		except (NotImplementedError, RuntimeError):
			info=obj.makeTextInfo(textInfos.POSITION_FIRST)
		info.expand(textInfos.UNIT_LINE)
		if scriptHandler.getLastScriptRepeatCount()==0:
			speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET)
		else:
			speech.speakSpelling(info.text)
	def script_review_currentCharacter(self,gesture):
		info=api.getReviewPosition().copy()
		info.expand(textInfos.UNIT_CHARACTER)
		scriptCount=scriptHandler.getLastScriptRepeatCount()
		if scriptCount==0:
			speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
		elif scriptCount==1:
			speech.speakSpelling(info.text,useCharacterDescriptions=True)
		else:
			try:
				c = ord(info.text)
				speech.speakMessage("%d," % c)
				speech.speakSpelling(hex(c))
			except:
				speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
	def poll(self, *args, **kwargs):
		self.pollTimer = None
		oldWord = self.previousWord or ""
		newWord = self.word or ""
		if newWord != oldWord:
			self.previousWord = newWord
			if len(newWord) > len(oldWord) and newWord[:len(oldWord)] == oldWord:
				speech.speakSpelling(newWord[len(oldWord):])
			elif newWord:
				speech.speakText(newWord)
				speech.speakSpelling(newWord)
			elif oldWord:
				# Translators: The text which is spoken when the spelling dialog is cleared.
				speech.speakText(_("cleared"))
		self.schedulePoll()
	def script_title(self,gesture):
		obj=api.getForegroundObject()
		title=obj.name
		if not isinstance(title,basestring) or not title or title.isspace():
			title=obj.appModule.appName  if obj.appModule else None
			if not isinstance(title,basestring) or not title or title.isspace():
				title=_("no title")
		repeatCount=scriptHandler.getLastScriptRepeatCount()
		if repeatCount==0:
			ui.message(title)
		elif repeatCount==1:
			speech.speakSpelling(title)
		else:
			if api.copyToClip(title):
				ui.message(_("%s copied to clipboard")%title)
	def poll(self, *args, **kwargs):
		self.pollTimer = None
		oldWord = self.previousWord or ""
		newWord = self.word or ""
		if newWord != oldWord:
			self.previousWord = newWord
			if len(newWord) > len(oldWord) and newWord[:len(oldWord)] == oldWord:
				speech.speakSpelling(newWord[len(oldWord):])
			elif newWord:
				speech.speakText(newWord)
				speech.speakSpelling(newWord)
			elif oldWord:
				# Translators: The text which is spoken when the spelling dialog is cleared.
				speech.speakText(_("cleared"))
		self.schedulePoll()
	def _reportUntranslated(self, pos):
		"""Report a braille cell which hasn't yet been translated into text.
		"""
		speakTyped = config.conf["keyboard"]["speakTypedCharacters"]
		protected = api.isTypingProtected()
		if speakTyped:
			if protected:
				speech.speakSpelling(speech.PROTECTED_CHAR)
			elif not self._table.contracted or not self._reportContractedCell(pos):
				dots = self.bufferBraille[pos]
				speakDots(dots)
		if self._table.contracted and (not speakTyped or protected):
			# Even if we're not speaking contracted cells, we might need to start doing so midword.
			# For example, the user might have speak typed characters disabled, but enable it midword.
			# Update state needed to report contracted cells.
			self._translateForReportContractedCell(pos)
		self._updateUntranslated()
		self.updateDisplay()
Example #21
0
	def _reportUntranslated(self, pos):
		"""Report a braille cell which hasn't yet been translated into text.
		"""
		speakTyped = config.conf["keyboard"]["speakTypedCharacters"]
		protected = api.isTypingProtected()
		if speakTyped:
			if protected:
				speech.speakSpelling(speech.PROTECTED_CHAR)
			elif not self._table.contracted or not self._reportContractedCell(pos):
				dots = self.bufferBraille[pos]
				speakDots(dots)
		if self._table.contracted and (not speakTyped or protected):
			# Even if we're not speaking contracted cells, we might need to start doing so midword.
			# For example, the user might have speak typed characters disabled, but enable it midword.
			# Update state needed to report contracted cells.
			self._translateForReportContractedCell(pos)
		self._updateUntranslated()
		self.updateDisplay()
Example #22
0
 def script_reportToEndOfLine(self, gesture):
     obj = api.getFocusObject()
     treeInterceptor = obj.treeInterceptor
     if hasattr(treeInterceptor,
                'TextInfo') and not treeInterceptor.passThrough:
         obj = treeInterceptor
     try:
         info = obj.makeTextInfo(textInfos.POSITION_CARET)
         info2 = info.copy()
     except (NotImplementedError, RuntimeError):
         info = obj.makeTextInfo(textInfos.POSITION_FIRST)
         info2 = info.copy()
     info.expand(textInfos.UNIT_LINE)
     info.setEndPoint(info2, "startToStart")
     if scriptHandler.getLastScriptRepeatCount() == 0:
         speech.speakTextInfo(info,
                              unit=textInfos.UNIT_LINE,
                              reason=controlTypes.REASON_CARET)
     else:
         speech.speakSpelling(info.text)
Example #23
0
	def _backspaceScriptHelper(self,unit,gesture):
		try:
			oldInfo=self.makeTextInfo(textInfos.POSITION_CARET)
		except:
			gesture.send()
			return
		oldBookmark=oldInfo.bookmark
		testInfo=oldInfo.copy()
		res=testInfo.move(textInfos.UNIT_CHARACTER,-1)
		if res<0:
			testInfo.expand(unit)
			delChunk=testInfo.text
		else:
			delChunk=""
		gesture.send()
		if not self._hasCaretMoved(oldBookmark):
			return
		if len(delChunk)>1:
			speech.speakMessage(delChunk)
		else:
			speech.speakSpelling(delChunk)
		self._caretScriptPostMovedHelper(None)
Example #24
0
def script_braille_routeTo(self, gesture):
    obj = obj = api.getNavigatorObject()
    if obj.hasFocus and braille.handler._cursorPos and (
            obj.role == controlTypes.ROLE_TERMINAL or
        (obj.role == controlTypes.ROLE_EDITABLETEXT
         and braille.handler.tether == braille.handler.TETHER_REVIEW)):
        speechMode = speech.speechMode
        speech.speechMode = 0
        nb = braille.handler._cursorPos - gesture.routingIndex
        i = 0
        key = "leftarrow" if nb > 0 else "rightarrow"
        while i < abs(nb):
            keyboardHandler.KeyboardInputGesture.fromName(key).send()
            i += 1
        speech.speechMode = speechMode
        speech.speakSpelling(getCurrentChar())
        return
    braille.handler.routeTo(gesture.routingIndex)
    if scriptHandler.getLastScriptRepeatCount(
    ) == 0 and config.conf["brailleExtender"]['speakRoutingTo']:
        ch = getCurrentChar()
        if ch != "": speech.speakSpelling(ch)
Example #25
0
def script_braille_routeTo(self, gesture):
    obj = obj = api.getNavigatorObject()
    if (config.conf["brailleExtender"]['routingReviewModeWithCursorKeys']
            and obj.hasFocus and braille.handler._cursorPos
            and (obj.role == controlTypes.ROLE_TERMINAL or
                 (obj.role == controlTypes.ROLE_EDITABLETEXT
                  and getTether() == braille.handler.TETHER_REVIEW))):
        speechMode = speech.speechMode
        speech.speechMode = 0
        nb = braille.handler._cursorPos - gesture.routingIndex
        i = 0
        key = "leftarrow" if nb > 0 else "rightarrow"
        while i < abs(nb):
            keyboardHandler.KeyboardInputGesture.fromName(key).send()
            i += 1
        speech.speechMode = speechMode
        speech.speakSpelling(getCurrentChar())
        return
    try:
        braille.handler.routeTo(gesture.routingIndex)
    except LookupError:
        pass
    if scriptHandler.getLastScriptRepeatCount(
    ) == 0 and config.conf["brailleExtender"]["speakRoutingTo"]:
        region = braille.handler.buffer
        if region.cursorPos is None: return
        try:
            start = region.brailleToRawPos[
                braille.handler.buffer.windowStartPos + gesture.routingIndex]
            _, endBraillePos = brailleRegionHelper.getBraillePosFromRawPos(
                region, start)
            end = region.brailleToRawPos[endBraillePos + 1]
            ch = region.rawText[start:end]
            if ch:
                speech.speakMessage(getSpeechSymbols(ch))
        except IndexError:
            pass
Example #26
0
def script_braille_routeTo(self, gesture):
    braille.handler.routeTo(gesture.routingIndex)
    if configBE.conf['general']['speakRoutingTo']:
        ch = getCurrentChar()
        if ch != "": speech.speakSpelling(ch)
def speakAndSpellWSRAlternatesPanelItem(obj):
	text = getCleanedWSRAlternatesPanelItemName(obj)
	speech.speakText(text)
	speech.speakSpelling(text)
Example #28
0
def speakAndSpellWSRAlternatesPanelItem(obj):
    text = getCleanedWSRAlternatesPanelItemName(obj)
    speech.speakText(text)
    speech.speakSpelling(text)
Example #29
0
	def reportFocus(self):
		errorText=self.errorText
		speech.speakObjectProperties(self,name=True,role=True)
		if errorText:
			speech.speakText(errorText)
			speech.speakSpelling(errorText)
Example #30
0
 def reportFocus(self):
     errorText = self.errorText
     speech.speakObjectProperties(self, name=True, role=True)
     if errorText:
         speech.speakText(errorText)
         speech.speakSpelling(errorText)