def _handleInputHelp(self, gesture, onlyLog=False): textList = [gesture.displayName] script = gesture.script runScript = False logMsg = "Input help: gesture %s" % gesture.identifiers[0] if script: scriptName = scriptHandler.getScriptName(script) logMsg += ", bound to script %s" % scriptName scriptLocation = scriptHandler.getScriptLocation(script) if scriptLocation: logMsg += " on %s" % scriptLocation if scriptName == "toggleInputHelp": runScript = True else: desc = script.__doc__ if desc: textList.append(desc) log.info(logMsg) if onlyLog: return import braille braille.handler.message("\t\t".join(textList)) # Punctuation must be spoken for the gesture name (the first chunk) so that punctuation keys are spoken. speech.speakText(textList[0], reason=controlTypes.REASON_MESSAGE, symbolLevel=characterProcessing.SYMLVL_ALL) for text in textList[1:]: speech.speakMessage(text) if runScript: script(gesture)
def _handleInputHelp(self, gesture, onlyLog=False): textList = [gesture.displayName] script = gesture.script runScript = False logMsg = "Input help: gesture %s"%gesture.logIdentifier if script: scriptName = scriptHandler.getScriptName(script) logMsg+=", bound to script %s" % scriptName scriptLocation = scriptHandler.getScriptLocation(script) if scriptLocation: logMsg += " on %s" % scriptLocation if scriptName == "toggleInputHelp": runScript = True else: desc = script.__doc__ if desc: textList.append(desc) log.info(logMsg) if onlyLog: return import braille braille.handler.message("\t\t".join(textList)) # Punctuation must be spoken for the gesture name (the first chunk) so that punctuation keys are spoken. speech.speakText(textList[0], reason=controlTypes.REASON_MESSAGE, symbolLevel=characterProcessing.SYMLVL_ALL) for text in textList[1:]: speech.speakMessage(text) if runScript: script(gesture)
def _inputCaptor(self, gesture): global suppressStatus if api.getFocusObject( ).windowControlID != 1003 or lastStatus == 'Recording.' or gesture.isNVDAModifierKey or gesture.isModifier: #if api.getForegroundObject().windowControlID != 68052 or lastStatus=='Recording.' or gesture.isNVDAModifierKey or gesture.isModifier: return True script = gesture.script lookup = assignedShortcuts.get(gesture.normalizedIdentifiers[1], None) if self._audacityInputHelp: scriptName = scriptHandler.getScriptName(script) if script else '' if scriptName == 'toggleAudacityInputHelp': return True if lookup: queueHandler.queueFunction(queueHandler.eventQueue, speech.speakMessage, lookup[2] + '->' + lookup[0]) if scriptName and not lookup: queueHandler.queueFunction(queueHandler.eventQueue, speech.speakMessage, scriptName) else: # don't speak "Stopped" for preview commands if lookup and lookup[0] in shouldNotReportStatus: suppressStatus = True else: suppressStatus = False if lookup and not lookup[0] in shouldNotAutoSpeak: queueHandler.queueFunction(queueHandler.eventQueue, speech.speakMessage, lookup[0]) return not self._audacityInputHelp
def executeGesture(self, gesture): if isinstance( gesture, (braille.BrailleDisplayGesture, brailleInput.BrailleInputGesture)): dict = { key: gesture.__dict__[key] for key in gesture.__dict__ if isinstance(gesture.__dict__[key], (int, str, bool)) } if gesture.script: name = scriptHandler.getScriptName(gesture.script) if name.startswith("kb"): location = ['globalCommands', 'GlobalCommands'] else: location = scriptHandler.getScriptLocation( gesture.script).rsplit(".", 1) dict["scriptPath"] = location + [name] else: scriptData = None maps = [ inputCore.manager.userGestureMap, inputCore.manager.localeGestureMap ] if braille.handler.display.gestureMap: maps.append(braille.handler.display.gestureMap) for map in maps: for identifier in gesture.identifiers: try: scriptData = next( map.getScriptsForGesture(identifier)) break except StopIteration: continue if scriptData: dict["scriptPath"] = [ scriptData[0].__module__, scriptData[0].__name__, scriptData[1] ] if hasattr(gesture, "source") and "source" not in dict: dict["source"] = gesture.source if hasattr(gesture, "model") and "model" not in dict: dict["model"] = gesture.model if hasattr(gesture, "id") and "id" not in dict: dict["id"] = gesture.id elif hasattr(gesture, "identifiers") and "identifiers" not in dict: dict["identifiers"] = gesture.identifiers if hasattr(gesture, "dots") and "dots" not in dict: dict["dots"] = gesture.dots if hasattr(gesture, "space") and "space" not in dict: dict["space"] = gesture.space if hasattr(gesture, "routingIndex") and "routingIndex" not in dict: dict["routingIndex"] = gesture.routingIndex self.call_callbacks('braille_input', **dict) else: self.orig_executeGesture(gesture)
def executeGesture(self, gesture): if isinstance(gesture,(braille.BrailleDisplayGesture,brailleInput.BrailleInputGesture)): dict = { key: gesture.__dict__[key] for key in gesture.__dict__ if isinstance(gesture.__dict__[key],(int,str,bool))} if gesture.script: name=scriptHandler.getScriptName(gesture.script) if name.startswith("kb"): location=['globalCommands', 'GlobalCommands'] else: location=scriptHandler.getScriptLocation(gesture.script).rsplit(".",1) dict["scriptPath"]=location+[name] else: scriptData=None maps=[inputCore.manager.userGestureMap,inputCore.manager.localeGestureMap] if braille.handler.display.gestureMap: maps.append(braille.handler.display.gestureMap) for map in maps: for identifier in gesture.identifiers: try: scriptData=next(map.getScriptsForGesture(identifier)) break except StopIteration: continue if scriptData: dict["scriptPath"]=[scriptData[0].__module__,scriptData[0].__name__,scriptData[1]] if hasattr(gesture,"source") and "source" not in dict: dict["source"]=gesture.source if hasattr(gesture,"model") and "model" not in dict: dict["model"]=gesture.model if hasattr(gesture,"id") and "id" not in dict: dict["id"]=gesture.id elif hasattr(gesture,"identifiers") and "identifiers" not in dict: dict["identifiers"]=gesture.identifiers if hasattr(gesture,"dots") and "dots" not in dict: dict["dots"]=gesture.dots if hasattr(gesture,"space") and "space" not in dict: dict["space"]=gesture.space if hasattr(gesture,"routingIndex") and "routingIndex" not in dict: dict["routingIndex"]=gesture.routingIndex self.call_callbacks('braille_input', **dict) else: self.orig_executeGesture(gesture)
def newHandleInputHelp(self, gesture, onlyLog=False): script = gesture.script scriptName = scriptHandler.getScriptName(script) if script else '' addDesc = ( # The script must exist script # And the script must not be input help script and scriptName != "toggleInputHelp" # And the script must not have already a description. and not getattr(script, '__doc__', None) ) if addDesc: desc = scriptName scriptLocation = scriptHandler.getScriptLocation(script) if scriptLocation: desc += " on %s" % scriptLocation script.__func__.__doc__ = desc script.__func__.category = SCRIPT_WITHOUT_DESC_CATEGORY GlobalPlugin.scriptsWithAddedDoc.add(script) res = _originalMethod(gesture, onlyLog) #if addDesc: # del script.__func__.__doc__ # del script.__func__.category return res