Setup - GavriYashar/Matlab-Editor-Plugin GitHub Wiki

General

matconsolectl: All code up to tags/original: Copyright (c) 2013, Joshua Kaplan)

  • the package was changed in Version 1.11 from at.justin.matlab to at.mep
  • be reminded, this is a "hobby" project I need for work, so after some time I forget about things I've done and should do. So when I'm updating and changing the code, things might break apart except the ones I personally use the most (e.g. the installer is probably the least used function). Which leads me to unit tests.

Installation

  • download the jar files from the latest release (V1.25). Make sure that there is only one of each jar file in destination folder.
  • execute MEP_V####.jar or follow the Manual Installation if the installer does not work.

Installer

broken
  • red means location is invalid either one or both *.jar files or javaclasspath.txt is not found.
  • browse to the location of *.jar files, or the javaclasspath.txt
    • if there is no javaclasspath.txt type winopen(prefdir) and create a javaclasspath.txt file (Matlab Help and More Help).
  • choose an installation directory for MEP
  • It may be necessary to manually remove Matlab's shortcut for Bookmarks (preferences>Matlab>Keyboard>Shortcut>Set/Clear Bookmark). On some systems the bookmark viewer and storage does not work when the shortcut is used within Matlab.

Alternatively you can run it via command line (not before V1.35) The first argument is the path to the folder containing both .jar files. The second argument is the path to javaclasspath.txt and the third argument is the installation directory.

java -jar .\MEP_1.35.jar "C:\...downloads" "C:\...\javaclasspath.txt" "C:\...\MEP"

What it does

The Installer will copy both *.jar files and *.properties to desired location and will modify the javaclasspath.txt accordingly.

Manual Installation

  • Copy both jar files to desired location (must be a user-writable folder) e.g. %appdata%\MathWorks\MATLAB\R2020b\MEP\

  • Open MEP_*.jar with any archive viewer (e.g. 7zip).

    • copy DefaultProps.properties from properties folder and insert it in the same folder as the *.jar files.
    • copy DefaultProps.properties and rename it to CustomProps.properties.
    • to enable live templates follow the instructions found here (optional)
    • to enable local history follow the instructions found here (optional)
  • Type edit javaclasspath.txt in matlab and add both of *.jar files

      C:\...\matconsolectl*.jar
      C:\...\MEP*.jar
    
    • optionally you can add them dynamically with javaaddpath('C:\Programme\Matlab\MEP\*.jar'), just make sure to add matconsolectl before MEP)

    • if there is no javaclasspath.txt type winopen(prefdir), create a javaclasspath.txt file (Matlab Help and More Help).

      MatLab documentation

      Create javaclasspath.txt File Each line in the javaclasspath.txt file contains a reference to a Java class folder or JAR file. To create the file:

      1. Create an ASCII text file named javaclasspath.txt.

      2. Enter the name of a Java class folder or JAR file, one per line. The format of the name depends on how the class is defined.

        • For classes defined in Java packages, see Add Packages.
        • For classes defined in individual .class files, see Add Individual (Unpackaged) Classes.
        • For classes defined in Java Archive (JAR) files, see Add JAR File Classes.
      3. Simplify folder specifications in cross-platform environments by using the $matlabroot, $arch, and $jre_home macros.

      4. Save the file in your preferences folder. To view the location of the preferences folder, type: prefdir

        Alternatively, save the javaclasspath.txt file in your MATLAB startup folder. To identify the startup folder, type pwd at the command line immediately after starting MATLAB. Classes specified in the javaclasspath.txt file in the startup folder appear on the path before classes specified in the file in the preferences folder. If a class appears in more than one folder or jar file, then Java uses the first one it finds.

      5. Restart MATLAB.

  • Manually remove Matlab's short cut for Bookmarks (preferences>Matlab>Keyboard>Shortcut>Set/Clear Bookmark), and set desired short cut in .properties file

    • the removal might not be necessary. On some systems it conflicts with MEP and the shortcut won't work)
  • restart Matlab (if static path was chosen)

  • continue with the sections below

Modifying Matlab's startup

If you want to start this plugin on every startup of Matlab you have to modify startup.m. Add the following:

    at.mep.Start.start('C:/.../CustomProps.properties', ...
                       'C:/.../DefaultProps.properties');

Creating custom key press callbacks in editor (optional)

Optional - Configuration

Examples create MyKeyReleaseFunction.m in Matlab's search path

   function out = MyKeyReleaseFunction(actionEvent)
       if nargin == 0; out = []; return; end
       % this is necessary, the first thing happen is trying find out whether 
       % the passed function is a valid matlab function or not
       % assignin('base','actionEvent',actionEvent)
       fprintf('ALT + INSERT\n')
       out = 1;
  • I strongly advise you not to debug these functions via keyboard command (matlab will most likely freeze). Instead call it from command line. If you need access to actionEvent use assignin('base','actionEvent',actionEvent)

after that go to your startup.m file and add these lines

    import at.mep.util.*;
    import at.mep.editor.*;

    ctrl = true;
    shift = true;
    alt = true;

    ks_MyKeyReleaseFunction = KeyStrokeUtil.getKeyStroke(java.awt.event.KeyEvent.VK_INSERT, ~ctrl, ~shift, alt, false);
    EditorApp.addMatlabCallback('MyKeyReleaseFunction', ks_MyKeyReleaseFunction , 'MyKeyReleaseFunction');

startup.m example

Your startup.m should look like something like this:

    % MEP-Startup (necessary)
    at.mep.Start.start('C:/.../CustomProps.properties', ...
                       'C:/.../DefaultProps.properties');

    % -~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=
    % Custom keyboard Shortcuts (Optional):
    import at.mep.util.*;
    import at.mep.editor.*;

    ctrl = true;
    shift = true;
    alt = true;
    
    % Example Shortcut
    ks_MyKeyReleaseFunction = KeyStrokeUtil.getKeyStroke(java.awt.event.KeyEvent.VK_INSERT, ~ctrl, ~shift, alt, false);
    EditorApp.addMatlabCallback('MyKeyReleaseFunction', ks_MyKeyReleaseFunction , 'MyKeyReleaseFunction');

For a complete list of Keyboard Constants follow this link: docs KeyEvent

Use VK_META instead of VK_CONTROL if you're on a MAC #150 (correct me if i'm wrong, i have zero experience regarding MACs).

Uninstall

  • Type edit javaclasspath.txt and remove the lines containing MEP_*.jar and matconsolect*.jar.
  • remove necessary lines from startup.m
  • close Matlab
  • remove files from installation folder
⚠️ **GitHub.com Fallback** ⚠️