Skip to content

Commit 4e3242f

Browse files
committed
Added matlab.py script.
1 parent 7b2dd7e commit 4e3242f

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This may include potential features in development, (to be included later in an
1212
* copy the script you want to install in the corresponding subfolder (appModules or globalPlugins) of the scratchpad folder.
1313

1414

15-
## Scripts
15+
## globalPlugins Scripts
1616

1717
### globalPlugins/autoLangSwitch.py
1818

@@ -29,6 +29,7 @@ This script provides information on any script in input help mode. If the execut
2929

3030
Executing a gesture bound to a script without description in input help mode also create an entry for this script in the gesture management dialog. This entry is located in a dedicated category called "Scripts without description (modify at your own risk!)". This allow to easily add, delete or change the native NVDA gestures for these script.
3131
Be aware however that it is often intended that such script do not have any description to prevent the user to modify the associated gesture. Indeed, the gesture may be defined to match an application shortcut key. For example the script script_toggleItalic on NVDAObjects.window.winword.WordDocument is bound to control+I and this should not be modified since the gesture is passed to the application to actually execute the shortcut key.
32+
3233
Known bug: A script added for a specific class is visible even if gesture manager is opened in another context.
3334

3435
### globalPlugins/debugTool.py
@@ -62,11 +63,17 @@ name, role, state, value, windowClassName, windowControlID, windowHandle, locati
6263
If you have installed [Speech history review and copying][3] addon from Tyler Spivey and James Scholes, you may use it to copy and paste the announced property to review it;
6364
review via copy/paste is especially useful for pythonClassMRO since it may be long.
6465

66+
## appModules scripts
67+
68+
### appModules/matlab.py
69+
70+
A script to issue some commands in Matlab console by just pressing a keystroke. E.g. press F5 to issue "dbcont" command.
71+
6572
## Removed scripts
6673

6774
### globalPlugins/startupOptionWorkaround.py
6875

69-
This script has been package as an add-on: [Startup option workaround add-on][4] that is itself deprecated.
76+
This script has been packaged as an add-on: [Startup option workaround add-on][4] that is itself deprecated.
7077

7178
With Windows 10 1903 update, NVDA may start after logon even when this is disabled in General settings panel (cf. [#9528][1]).
7279
This script does not fix the issue. However, as a work-around, it unloads NVDA just after startup in the case it should not have started up at all.

appModules/matlab.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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

Comments
 (0)