|
| 1 | +# Matlab App Module for NVDA |
| 2 | + |
| 3 | + |
| 4 | +import appModuleHandler |
| 5 | +from NVDAObjects.behaviors import Terminal |
| 6 | +import controlTypes |
| 7 | + |
| 8 | +SEND_CMD = 'sendCommand' |
| 9 | + |
| 10 | +class AppModule(appModuleHandler.AppModule): |
| 11 | + |
| 12 | + # Allow this to be overridden for derived applications. |
| 13 | + #TERMINAL_WINDOW_CLASS = "MATLAB" |
| 14 | + |
| 15 | + def chooseNVDAObjectOverlayClasses(self, obj, clsList): |
| 16 | + import NVDAObjects.behaviors, NVDAObjects.window, NVDAObjects.window.winConsole |
| 17 | + if obj.windowClassName == "Edit" and obj.role == controlTypes.ROLE_EDITABLETEXT: |
| 18 | + #obj.STABILIZE_DELAY = 0 |
| 19 | + clsList[0:0] = [ |
| 20 | + NVDAObjects.behaviors.Terminal, |
| 21 | + NVDAObjects.window.DisplayModelLiveText, |
| 22 | + NVDAObjects.window.DisplayModelEditableText, |
| 23 | + ] |
| 24 | + |
| 25 | + |
| 26 | + if False and obj.windowClassName == "Edit" and obj.role == controlTypes.ROLE_EDITABLETEXT: |
| 27 | + from NVDAObjects.window import DisplayModelEditableText, DisplayModelLiveText |
| 28 | + from NVDAObjects.window import winConsole #.WinConsole |
| 29 | + try: |
| 30 | + clsList.remove(DisplayModelEditableText) |
| 31 | + except ValueError: |
| 32 | + pass |
| 33 | + #clsList[0:0] = (winConsole.WinConsole, Terminal, DisplayModelLiveText) |
| 34 | + clsList[0:0] = (Terminal, DisplayModelLiveText) |
| 35 | + |
| 36 | + def __init__(self, *args, **kw): |
| 37 | + super(AppModule, self).__init__(*args, **kw) |
| 38 | + self.commandTable = [ |
| 39 | + ('DbCont', 'dbcont', 'kb:F5'), |
| 40 | + ('DbStepIn', 'dbstepin', 'kb:F8'), |
| 41 | + ('DbStepOut', 'dbstepout', 'kb:control+shift+F8'), |
| 42 | + ('DbStep', 'dbstep', 'kb:shift+F8'), |
| 43 | + ('DbQuit', 'dbquit', 'kb:shift+escape'), |
| 44 | + ('ClearSound', 'clear sound', 'kb:F7'), |
| 45 | + ('GoToCurrentExecPoint', '', 'kb:control+shift+G'), |
| 46 | + ] |
| 47 | + self.createAllScript_sendCommand() |
| 48 | + dicGestures = {gesture: SEND_CMD+name for name,cmd,gesture in self.commandTable} |
| 49 | + self.bindGestures(dicGestures) |
| 50 | + |
| 51 | + def sendCommand(self, sCmd, gesture): |
| 52 | + import brailleInput |
| 53 | + import inputCore |
| 54 | + import keyboardHandler |
| 55 | + #inputCore.manager.emulateGesture(keyboardHandler.KeyboardInputGesture.fromName("home")) |
| 56 | + #inputCore.manager.emulateGesture(keyboardHandler.KeyboardInputGesture.fromName("control+delete")) |
| 57 | + brailleInput.handler.sendChars(sCmd) |
| 58 | + inputCore.manager.emulateGesture(keyboardHandler.KeyboardInputGesture.fromName("enter")) |
| 59 | + |
| 60 | + def DISABLED_zzz_chooseNVDAObjectOverlayClasses(self, obj, clsList): |
| 61 | + if obj.windowClassName == "Edit" and obj.role == controlTypes.ROLE_EDITABLETEXT: |
| 62 | + #clsList.insert(0, EnhancedEditField) |
| 63 | + clsList.insert(0, Terminal) |
| 64 | + |
| 65 | + @staticmethod |
| 66 | + def _createScript_sendCommand(name, cmd): |
| 67 | + def _genericScript_sendCommand(self, gesture): |
| 68 | + self.sendCommand(cmd,gesture) |
| 69 | + #Translators: Input help mode message pattern for the script used to send commands to Matlab. |
| 70 | + _genericScript_sendCommand.__doc__ = _("Send a command to Matlab: {name}").format(name=name) |
| 71 | + return _genericScript_sendCommand |
| 72 | + |
| 73 | + |
| 74 | + def createAllScript_sendCommand(self): |
| 75 | + for name, cmd, gesture in self.commandTable: |
| 76 | + scriptName = 'script_' + SEND_CMD + name |
| 77 | + scriptFun = self._createScript_sendCommand(scriptName, cmd) |
| 78 | + setattr(self.__class__, scriptName, scriptFun) |
| 79 | + |
| 80 | +AppModule.scriptCategory = _("Matlab") |
| 81 | + |
0 commit comments