コード例 #1
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 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)
コード例 #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)
コード例 #3
0
	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)
コード例 #4
0
	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)
コード例 #5
0
	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
コード例 #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)
コード例 #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)
コード例 #8
0
	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))
コード例 #9
0
	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"))
コード例 #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)
コード例 #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)
コード例 #12
0
	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)
コード例 #13
0
ファイル: winword.py プロジェクト: atsuoishimoto/tweetitloud
	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)
コード例 #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()
コード例 #15
0
	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)
コード例 #16
0
	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)
コード例 #17
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:
				# Translators: The text which is spoken when the spelling dialog is cleared.
				speech.speakText(_("cleared"))
		self.schedulePoll()
コード例 #18
0
	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)
コード例 #19
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:
				# Translators: The text which is spoken when the spelling dialog is cleared.
				speech.speakText(_("cleared"))
		self.schedulePoll()
コード例 #20
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()
コード例 #21
0
ファイル: brailleInput.py プロジェクト: eklipse2009/nvda
	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()
コード例 #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)
コード例 #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)
コード例 #24
0
ファイル: patchs.py プロジェクト: daniel-1964/BrailleExtender
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)
コード例 #25
0
ファイル: patchs.py プロジェクト: dawidpieper/BrailleExtender
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
コード例 #26
0
ファイル: patchs.py プロジェクト: YetiAnt/BrailleExtender
def script_braille_routeTo(self, gesture):
    braille.handler.routeTo(gesture.routingIndex)
    if configBE.conf['general']['speakRoutingTo']:
        ch = getCurrentChar()
        if ch != "": speech.speakSpelling(ch)
コード例 #27
0
def speakAndSpellWSRAlternatesPanelItem(obj):
	text = getCleanedWSRAlternatesPanelItemName(obj)
	speech.speakText(text)
	speech.speakSpelling(text)
コード例 #28
0
def speakAndSpellWSRAlternatesPanelItem(obj):
    text = getCleanedWSRAlternatesPanelItemName(obj)
    speech.speakText(text)
    speech.speakSpelling(text)
コード例 #29
0
ファイル: winword.py プロジェクト: lpintes/NVDA
	def reportFocus(self):
		errorText=self.errorText
		speech.speakObjectProperties(self,name=True,role=True)
		if errorText:
			speech.speakText(errorText)
			speech.speakSpelling(errorText)
コード例 #30
0
ファイル: winword.py プロジェクト: mai-codes/evoHax-nvda
 def reportFocus(self):
     errorText = self.errorText
     speech.speakObjectProperties(self, name=True, role=True)
     if errorText:
         speech.speakText(errorText)
         speech.speakSpelling(errorText)