def lineReached(self, obj, bookmark, state): # We've just started speaking this line, so move the cursor there. state.updateObj() updater = obj.makeTextInfo(bookmark) self.updateCaret(updater) winKernel.SetThreadExecutionState(winKernel.ES_SYSTEM_REQUIRED) if self.numBufferedLines == 0: # This was the last line spoken, so move on. self.nextLine() else: self.numBufferedLines -= 1
def lineReached(self, obj, bookmark, state): # We've just started speaking this line, so move the cursor there. state.updateObj() updater = obj.makeTextInfo(bookmark) if self.cursor == CURSOR_CARET: updater.updateCaret() if self.cursor != CURSOR_CARET or config.conf["reviewCursor"]["followCaret"]: api.setReviewPosition(updater, isCaret=self.cursor==CURSOR_CARET) winKernel.SetThreadExecutionState(winKernel.ES_SYSTEM_REQUIRED | winKernel.ES_DISPLAY_REQUIRED) if self.numBufferedLines == 0: # This was the last line spoken, so move on. self.nextLine() else: self.numBufferedLines -= 1
def next(self): if not self.walker: # We were stopped. return if self.prevObj: # We just started speaking this object, so move the navigator to it. api.setNavigatorObject(self.prevObj, isFocus=lastSayAllMode==CURSOR_CARET) winKernel.SetThreadExecutionState(winKernel.ES_SYSTEM_REQUIRED | winKernel.ES_DISPLAY_REQUIRED) # Move onto the next object. self.prevObj = obj = next(self.walker, None) if not obj: return # Call this method again when we start speaking this object. callbackCommand = speech.CallbackCommand(self.next, name="say-all:next") speech.speakObject(obj, reason=controlTypes.REASON_SAYALL, _prefixSpeechCommand=callbackCommand)
def executeGesture(self, gesture): """Perform the action associated with a gesture. @param gesture: The gesture to execute. @type gesture: L{InputGesture} @raise NoInputGestureAction: If there is no action to perform. """ if watchdog.isAttemptingRecovery: # The core is dead, so don't try to perform an action. # This lets gestures pass through unhindered where possible, # as well as stopping a flood of actions when the core revives. raise NoInputGestureAction script = gesture.script focus = api.getFocusObject() if focus.sleepMode is focus.SLEEP_FULL or ( focus.sleepMode and not getattr(script, 'allowInSleepMode', False)): raise NoInputGestureAction wasInSayAll = False if gesture.isModifier: if not self.lastModifierWasInSayAll: wasInSayAll = self.lastModifierWasInSayAll = sayAllHandler.isRunning( ) elif self.lastModifierWasInSayAll: wasInSayAll = True self.lastModifierWasInSayAll = False else: wasInSayAll = sayAllHandler.isRunning() if wasInSayAll: gesture.wasInSayAll = True speechEffect = gesture.speechEffectWhenExecuted if speechEffect == gesture.SPEECHEFFECT_CANCEL: queueHandler.queueFunction(queueHandler.eventQueue, speech.cancelSpeech) elif speechEffect in (gesture.SPEECHEFFECT_PAUSE, gesture.SPEECHEFFECT_RESUME): queueHandler.queueFunction( queueHandler.eventQueue, speech.pauseSpeech, speechEffect == gesture.SPEECHEFFECT_PAUSE) if gesture.shouldPreventSystemIdle: winKernel.SetThreadExecutionState(winKernel.ES_SYSTEM_REQUIRED) if log.isEnabledFor(log.IO) and not gesture.isModifier: self._lastInputTime = time.time() log.io("Input: %s" % gesture.identifiers[0]) if self._captureFunc: try: if self._captureFunc(gesture) is False: return except: log.error("Error in capture function, disabling", exc_info=True) self._captureFunc = None if gesture.isModifier: raise NoInputGestureAction if config.conf["keyboard"][ "speakCommandKeys"] and gesture.shouldReportAsCommand: queueHandler.queueFunction(queueHandler.eventQueue, speech.speakMessage, gesture.displayName) gesture.reportExtra() # #2953: if an intercepted command Script (script that sends a gesture) is queued # then queue all following gestures (that don't have a script) with a fake script so that they remain in order. if not script and scriptHandler._numIncompleteInterceptedCommandScripts: script = lambda gesture: gesture.send() if script: scriptHandler.queueScript(script, gesture) return else: # Clear memorized last script to avoid getLastScriptRepeatCount detect a repeat # in case an unbound gesture is executed between two identical bound gestures. queueHandler.queueFunction(queueHandler.eventQueue, scriptHandler.clearLastScript) raise NoInputGestureAction
def executeKeyboardGesture(self, gesture, bypassRemanence=False): """Perform the action associated with a gesture. @param gesture: The gesture to execute @type gesture: L{InputGesture} @raise NoInputGestureAction: If there is no action to perform. """ if not hasattr(gesture, "noAction"): gesture.noAction = False if watchdog.isAttemptingRecovery: # The core is dead, so don't try to perform an action. # This lets gestures pass through unhindered where possible, # as well as stopping a flood of actions when the core revives. raise NoInputGestureAction newGesture = self.manageRemanence( gesture) if not bypassRemanence else None if newGesture is not None: queueHandler.queueFunction(queueHandler.eventQueue, self.executeNewGesture, newGesture) return newGesture = self.getNumpadKeyReplacement(gesture) if newGesture is not None: queueHandler.queueFunction(queueHandler.eventQueue, self.executeNewGesture, newGesture) return script = gesture.script focus = api.getFocusObject() if focus.sleepMode is focus.SLEEP_FULL\ or (focus.sleepMode and not getattr(script, 'allowInSleepMode', False)): raise NoInputGestureAction wasInSayAll = False if gesture.isModifier: if not _NVDA_InputManager.lastModifierWasInSayAll: wasInSayAll = _NVDA_InputManager.lastModifierWasInSayAll = sayAllHandler.isRunning( ) elif _NVDA_InputManager.lastModifierWasInSayAll: wasInSayAll = True _NVDA_InputManager.lastModifierWasInSayAll = False else: wasInSayAll = sayAllHandler.isRunning() if wasInSayAll: gesture.wasInSayAll = True speechEffect = gesture.speechEffectWhenExecuted if speechEffect == gesture.SPEECHEFFECT_CANCEL: queueHandler.queueFunction(queueHandler.eventQueue, speech.cancelSpeech) elif speechEffect in (gesture.SPEECHEFFECT_PAUSE, gesture.SPEECHEFFECT_RESUME): queueHandler.queueFunction( queueHandler.eventQueue, speech.pauseSpeech, speechEffect == gesture.SPEECHEFFECT_PAUSE) if gesture.shouldPreventSystemIdle: winKernel.SetThreadExecutionState(winKernel.ES_SYSTEM_REQUIRED | winKernel.ES_DISPLAY_REQUIRED) if log.isEnabledFor(log.IO) and not gesture.isModifier: _NVDA_InputManager._lastInputTime = time.time() log.io("Input: %s" % gesture.identifiers[0]) if _NVDA_InputManager._captureFunc: try: if _NVDA_InputManager._captureFunc(gesture) is False: return except Exception: log.error("Error in capture function, disabling", exc_info=True) _NVDA_InputManager._captureFunc = None if gesture.isModifier: if gesture.noAction: gesture.normalizedModifiers = [] return raise NoInputGestureAction self.speakGesture(gesture) if not script: gesture.reportExtra() # then queue all following gestures # (that don't have a script # ) with a fake script so that they remain in order. if not script and ( bypassRemanence or scriptHandler._numIncompleteInterceptedCommandScripts): script = lambda gesture: gesture.send() if script: scriptHandler.queueScript(script, gesture) return raise NoInputGestureAction