[Nvda-dev] commit r2392 - in trunk/source: . NVDAObjects NVDAObjects/IAccessible appModules

NVDA Subversion svn at nvda-project.org
Wed Sep 24 05:54:41 UTC 2008


Author: mdcurran
Date: Wed Sep 24 05:54:41 2008
New Revision: 2392

Log:
Added api.getReviewPosition and api.setReviewPosition. These functions should be nowused rather than accessing globalVars.reviewPosition directly. The review position and navigator object are tighed together much more tightly now, as in if you set the navigator object, the review position gets set to None and therefore when retreaving it next time, it is gotten from the navigator object. Same when setting the review position, the navigator object is set to None, and therefore when getting the navigator object next time, it has to be gotton from the review position, using NVDAObjectAtStart. There is also now specific support for virtualBuffers in regards to review/object navigation, in that when you move the navigator object to an object inside a virtualBuffer, the review position will actually be inside the buffer, at the position of that NVDAObject, rather than just directly in that NVDAObject. This all now means that you can navigate hyerarchically through a web page using object navigation, and then at any point start reviewing the text from that point. Perhaps this may need to be made in to a config option, if people do really want to review a specific object's text.

Modified:
   trunk/source/NVDAObjects/IAccessible/winConsole.py
   trunk/source/NVDAObjects/__init__.py
   trunk/source/api.py
   trunk/source/appModules/_default.py
   trunk/source/sayAllHandler.py

Modified: trunk/source/NVDAObjects/IAccessible/winConsole.py
==============================================================================
--- trunk/source/NVDAObjects/IAccessible/winConsole.py	(original)
+++ trunk/source/NVDAObjects/IAccessible/winConsole.py	Wed Sep 24 05:54:41 2008
@@ -9,6 +9,7 @@
 import ctypes
 import difflib
 import pythoncom
+import api
 import globalVars
 from logHandler import log
 import queueHandler
@@ -71,8 +72,8 @@
 		self.basicTextLineLength=lineLength
 		self.prevConsoleVisibleLines=[self.basicText[x:x+lineLength] for x in xrange(0,len(self.basicText),lineLength)]
 		info=winKernel.getConsoleScreenBufferInfo(self.consoleHandle)
-		if globalVars.caretMovesReviewCursor and self==globalVars.reviewPosition.obj:
-			globalVars.reviewPosition=self.makeTextInfo(textHandler.POSITION_CARET)
+		if globalVars.caretMovesReviewCursor and self==api.getReviewPosition().obj:
+			api.setReviewPosition(self.makeTextInfo(textHandler.POSITION_CARET))
 		self.monitorThread=threading.Thread(target=self.monitorThreadFunc)
 		self.monitorThread.start()
 		pythoncom.PumpWaitingMessages()
@@ -113,8 +114,8 @@
 			return
 		info=winKernel.getConsoleScreenBufferInfo(self.consoleHandle)
 		#Update the review cursor position with the caret position
-		if globalVars.caretMovesReviewCursor and self==globalVars.reviewPosition.obj:
-			globalVars.reviewPosition=self.makeTextInfo(textHandler.POSITION_CARET)
+		if globalVars.caretMovesReviewCursor and self==api.getReviewPosition().obj:
+			api.setReviewPosition(self.makeTextInfo(textHandler.POSITION_CARET))
 		#For any events other than caret movement, we want to let the monitor thread know that there might be text to speak
 		if eventID!=winUser.EVENT_CONSOLE_CARET:
 			self.lastConsoleEvent=eventID

Modified: trunk/source/NVDAObjects/__init__.py
==============================================================================
--- trunk/source/NVDAObjects/__init__.py	(original)
+++ trunk/source/NVDAObjects/__init__.py	Wed Sep 24 05:54:41 2008
@@ -738,7 +738,7 @@
 			except:
 				return
 			if globalVars.caretMovesReviewCursor:
-				globalVars.reviewPosition=info.copy()
+				api.setReviewPosition(info.copy())
 			info.expand(textHandler.UNIT_LINE)
 			speech.speakTextInfo(info)
 
@@ -759,7 +759,7 @@
 			except:
 				return
 			if globalVars.caretMovesReviewCursor:
-				globalVars.reviewPosition=info.copy()
+				api.setReviewPosition(info.copy())
 			info.expand(textHandler.UNIT_CHARACTER)
 			speech.speakTextInfo(info,handleSymbols=True,extraDetail=True)
 
@@ -780,7 +780,7 @@
 			except:
 				return
 			if globalVars.caretMovesReviewCursor:
-				globalVars.reviewPosition=info.copy()
+				api.setReviewPosition(info.copy())
 			info.expand(textHandler.UNIT_WORD)
 			speech.speakTextInfo(info,extraDetail=True,handleSymbols=True)
 
@@ -801,7 +801,7 @@
 			except:
 				return
 			if globalVars.caretMovesReviewCursor:
-				globalVars.reviewPosition=info.copy()
+				api.setReviewPosition(info.copy())
 			info.expand(textHandler.UNIT_PARAGRAPH)
 			speech.speakTextInfo(info)
 
@@ -828,7 +828,7 @@
 			except:
 				return
 			if globalVars.caretMovesReviewCursor:
-				globalVars.reviewPosition=info
+				api.setReviewPosition(info)
 
 	def script_delete(self,keyPress):
 		try:
@@ -847,7 +847,7 @@
 			except:
 				return
 			if globalVars.caretMovesReviewCursor:
-				globalVars.reviewPosition=info.copy()
+				api.setReviewPosition(info.copy())
 			info.expand(textHandler.UNIT_CHARACTER)
 			speech.speakTextInfo(info,handleSymbols=True)
 

Modified: trunk/source/api.py
==============================================================================
--- trunk/source/api.py	(original)
+++ trunk/source/api.py	Wed Sep 24 05:54:41 2008
@@ -157,15 +157,43 @@
 		log.debug("%s %s %s %s"%(obj.name or "",controlTypes.speechRoleLabels[obj.role],obj.value or "",obj.description or ""))
 	globalVars.desktopObject=obj
 
+def getReviewPosition():
+	"""Retreaves the current TextInfo instance representing the user's review position. If it is not set, it uses the user's set navigator object and creates a TextInfo from that.
+	"""
+	if globalVars.reviewPosition: 
+		return globalVars.reviewPosition
+	else:
+		try:
+			globalVars.reviewPosition=globalVars.navigatorObject.virtualBuffer.makeTextInfo(globalVars.navigatorObject)
+			return globalVars.reviewPosition
+		except:
+			pass
+		try:
+			globalVars.reviewPosition=globalVars.navigatorObject.makeTextInfo(textHandler.POSITION_CARET)
+			return globalVars.reviewPosition
+		except:
+			globalVars.reviewPosition=globalVars.navigatorObject.makeTextInfo(textHandler.POSITION_FIRST)
+			return globalVars.reviewPosition
+
+def setReviewPosition(reviewPosition):
+	"""Sets a TextInfo instance as the review position. It sets the current navigator object to None so that the next time the navigator object is asked for it fetches it from the review position.
+	"""
+	globalVars.reviewPosition=reviewPosition
+	globalVars.navigatorObject=None
+
 def getNavigatorObject():
-	"""Gets the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. 
+	"""Gets the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. If the navigator object is not set, it fetches it from the review position. 
 @returns: the current navigator object
 @rtype: L{NVDAObjects.NVDAObject}
 """
-	return globalVars.navigatorObject
+	if globalVars.navigatorObject:
+		return globalVars.navigatorObject
+	else:
+		globalVars.navigatorObject=globalVars.reviewPosition.NVDAObjectAtStart
+		return globalVars.navigatorObject
 
 def setNavigatorObject(obj):
-	"""Sets an object to be the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus.  
+	"""Sets an object to be the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. It also sets the current review position to None so that next time the review position is asked for, it is created from the navigator object.  
 @param obj: the object that will be set as the current navigator object
 @type obj: NVDAObjects.NVDAObject  
 """
@@ -174,10 +202,7 @@
 	if log.isEnabledFor(log.DEBUG):
 		log.debug("%s %s %s %s"%(obj.name or "",controlTypes.speechRoleLabels[obj.role],obj.value or "",obj.description or ""))
 	globalVars.navigatorObject=obj
-	try:
-		globalVars.reviewPosition=obj.makeTextInfo(textHandler.POSITION_CARET)
-	except:
-		globalVars.reviewPosition=obj.makeTextInfo(textHandler.POSITION_FIRST)
+	globalVars.reviewPosition=None
 
 def isTypingProtected():
 	"""Checks to see if key echo should be suppressed because the focus is currently on an object that has its protected state set.

Modified: trunk/source/appModules/_default.py
==============================================================================
--- trunk/source/appModules/_default.py	(original)
+++ trunk/source/appModules/_default.py	Wed Sep 24 05:54:41 2008
@@ -163,7 +163,7 @@
 		speech.speakMessage(_("Move mouse to navigator"))
 		obj=api.getNavigatorObject() 
 		try:
-			p=globalVars.reviewPosition.pointAtStart
+			p=api.getReviewPosition().pointAtStart
 		except NotImplementedError:
 			p=None
 		if p:
@@ -357,19 +357,19 @@
 	script_navigatorObject_where.__doc__=_("Reports where the current navigator object is by reporting each of its ancestors")
 
 	def script_review_top(self,keyPress):
-		info=globalVars.reviewPosition.obj.makeTextInfo(textHandler.POSITION_FIRST)
-		globalVars.reviewPosition=info.copy()
+		info=api.setReviewPosition().obj.makeTextInfo(textHandler.POSITION_FIRST)
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_LINE)
 		speech.speakMessage(_("top"))
 		speech.speakTextInfo(info)
 	script_review_top.__doc__=_("Moves the review cursor to the top line of the current navigator object and speaks it")
 
 	def script_review_previousLine(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_LINE)
 		info.collapse()
 		res=info.move(textHandler.UNIT_LINE,-1)
-		globalVars.reviewPosition=info.copy()
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_LINE)
 		if res==0:
 			speech.speakMessage(_("top"))
@@ -377,7 +377,7 @@
 	script_review_previousLine.__doc__=_("Moves the review cursor to the previous line of the current navigator object and speaks it")
 
 	def script_review_currentLine(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_LINE)
 		if scriptHandler.getLastScriptRepeateCount()==0:
 			speech.speakTextInfo(info)
@@ -386,11 +386,11 @@
 	script_review_currentLine.__doc__=_("Reports the line of the current navigator object where the review cursor is situated. If this key is pressed twice, the current line will be spelled")
 
 	def script_review_nextLine(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_LINE)
 		info.collapse()
 		res=info.move(textHandler.UNIT_LINE,1)
-		globalVars.reviewPosition=info.copy()
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_LINE)
 		if res==0:
 			speech.speakMessage(_("bottom"))
@@ -398,19 +398,19 @@
 	script_review_nextLine.__doc__=_("Moves the review cursor to the next line of the current navigator object and speaks it")
 
 	def script_review_bottom(self,keyPress):
-		info=globalVars.reviewPosition.obj.makeTextInfo(textHandler.POSITION_LAST)
-		globalVars.reviewPosition=info.copy()
+		info=api.getReviewPosition().obj.makeTextInfo(textHandler.POSITION_LAST)
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_LINE)
 		speech.speakMessage(_("bottom"))
 		speech.speakTextInfo(info)
 	script_review_bottom.__doc__=_("Moves the review cursor to the bottom line of the current navigator object and speaks it")
 
 	def script_review_previousWord(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_WORD)
 		info.collapse()
 		res=info.move(textHandler.UNIT_WORD,-1)
-		globalVars.reviewPosition=info.copy()
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_WORD)
 		if res==0:
 			speech.speakMessage(_("top"))
@@ -418,7 +418,7 @@
 	script_review_previousWord.__doc__=_("Moves the review cursor to the previous word of the current navigator object and speaks it")
 
 	def script_review_currentWord(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_WORD)
 		if scriptHandler.getLastScriptRepeateCount()==0:
 			speech.speakTextInfo(info)
@@ -427,11 +427,11 @@
 	script_review_currentWord.__doc__=_("Speaks the word of the current navigator object where the review cursor is situated. If this key is pressed twice, the word will be spelled")
 
 	def script_review_nextWord(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_WORD)
 		info.collapse()
 		res=info.move(textHandler.UNIT_WORD,1)
-		globalVars.reviewPosition=info.copy()
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_WORD)
 		if res==0:
 			speech.speakMessage(_("bottom"))
@@ -439,35 +439,35 @@
 	script_review_nextWord.__doc__=_("Moves the review cursor to the next word of the current navigator object and speaks it")
 
 	def script_review_startOfLine(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_LINE)
 		info.collapse()
-		globalVars.reviewPosition=info.copy()
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_CHARACTER)
 		speech.speakMessage(_("left"))
 		speech.speakTextInfo(info,handleSymbols=True)
 	script_review_startOfLine.__doc__=_("Moves the review cursor to the first character of the line where it is situated in the current navigator object and speaks it")
 
 	def script_review_previousCharacter(self,keyPress):
-		lineInfo=globalVars.reviewPosition.copy()
+		lineInfo=api.getReviewPosition().copy()
 		lineInfo.expand(textHandler.UNIT_LINE)
-		charInfo=globalVars.reviewPosition.copy()
+		charInfo=api.getReviewPosition().copy()
 		charInfo.expand(textHandler.UNIT_CHARACTER)
 		charInfo.collapse()
 		res=charInfo.move(textHandler.UNIT_CHARACTER,-1)
 		if res==0 or charInfo.compareEndPoints(lineInfo,"startToStart")<0:
 			speech.speakMessage(_("left"))
-			reviewInfo=globalVars.reviewPosition.copy()
+			reviewInfo=api.getReviewPosition().copy()
 			reviewInfo.expand(textHandler.UNIT_CHARACTER)
 			speech.speakSpelling(reviewInfo.text)
 		else:
-			globalVars.reviewPosition=charInfo.copy()
+			api.setReviewPosition(charInfo.copy())
 			charInfo.expand(textHandler.UNIT_CHARACTER)
 			speech.speakTextInfo(charInfo,handleSymbols=True)
 	script_review_previousCharacter.__doc__=_("Moves the review cursor to the previous character of the current navigator object and speaks it")
 
 	def script_review_currentCharacter(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_CHARACTER)
 		if scriptHandler.getLastScriptRepeateCount()==0:
 			speech.speakTextInfo(info,handleSymbols=True)
@@ -481,44 +481,44 @@
 	script_review_currentCharacter.__doc__=_("Reports the character of the current navigator object where the review cursor is situated. If this key is pressed twice, ascii and hexadecimal values are spoken for the character")
 
 	def script_review_nextCharacter(self,keyPress):
-		lineInfo=globalVars.reviewPosition.copy()
+		lineInfo=api.getReviewPosition().copy()
 		lineInfo.expand(textHandler.UNIT_LINE)
-		charInfo=globalVars.reviewPosition.copy()
+		charInfo=api.getReviewPosition().copy()
 		charInfo.expand(textHandler.UNIT_CHARACTER)
 		charInfo.collapse()
 		res=charInfo.move(textHandler.UNIT_CHARACTER,1)
 		if res==0 or charInfo.compareEndPoints(lineInfo,"endToEnd")>=0:
 			speech.speakMessage(_("right"))
-			reviewInfo=globalVars.reviewPosition.copy()
+			reviewInfo=api.getReviewPosition().copy()
 			reviewInfo.expand(textHandler.UNIT_CHARACTER)
 			speech.speakSpelling(reviewInfo.text)
 		else:
-			globalVars.reviewPosition=charInfo.copy()
+			api.setReviewPosition(charInfo.copy())
 			charInfo.expand(textHandler.UNIT_CHARACTER)
 			speech.speakTextInfo(charInfo,handleSymbols=True)
 	script_review_nextCharacter.__doc__=_("Moves the review cursor to the next character of the current navigator object and speaks it")
 
 	def script_review_endOfLine(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_LINE)
 		info.collapse(end=True)
 		info.move(textHandler.UNIT_CHARACTER,-1)
-		globalVars.reviewPosition=info.copy()
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_CHARACTER)
 		speech.speakMessage(_("right"))
 		speech.speakTextInfo(info,handleSymbols=True)
 	script_review_endOfLine.__doc__=_("Moves the review cursor to the last character of the line where it is situated in the current navigator object and speaks it")
 
 	def script_review_moveToCaret(self,keyPress):
-		info=globalVars.reviewPosition.obj.makeTextInfo(textHandler.POSITION_CARET)
-		globalVars.reviewPosition=info.copy()
+		info=api.getReviewPosition().obj.makeTextInfo(textHandler.POSITION_CARET)
+		api.setReviewPosition(info.copy())
 		info.expand(textHandler.UNIT_LINE)
 		speech.speakTextInfo(info)
 	script_review_moveToCaret.__doc__=_("Moves the review cursor to the position of the system caret, in the current navigator object")
 
 	def script_review_moveCaretHere(self,keyPress):
-		globalVars.reviewPosition.updateCaret()
-		info=globalVars.reviewPosition.copy()
+		api.getReviewPosition().updateCaret()
+		info=api.getReviewPosition().copy()
 		info.expand(textHandler.UNIT_LINE)
 		speech.speakTextInfo(info)
 	script_review_moveCaretHere.__doc__=_("Moves the system caret to the position of the review cursor , in the current navigator object")
@@ -555,7 +555,7 @@
 	script_showGui.__doc__=_("Shows the NVDA menu")
 
 	def script_review_sayAll(self,keyPress):
-		info=globalVars.reviewPosition.copy()
+		info=api.getReviewPosition().copy()
 		sayAllHandler.readText(info,sayAllHandler.CURSOR_REVIEW)
 	script_review_sayAll.__doc__ = _("reads from the review cursor  up to end of current text, moving the review cursor as it goes")
 

Modified: trunk/source/sayAllHandler.py
==============================================================================
--- trunk/source/sayAllHandler.py	(original)
+++ trunk/source/sayAllHandler.py	Wed Sep 24 05:54:41 2008
@@ -125,7 +125,7 @@
 				if cursor==CURSOR_CARET:
 					updater.updateCaret()
 				if cursor!=CURSOR_CARET or globalVars.caretMovesReviewCursor:
-					globalVars.reviewPosition=updater
+					api.setReviewPosition(updater)
 		while speech.isPaused:
 			yield
 		yield



More information about the Nvda-dev mailing list