Module jEdit

Class Macros

java.lang.Object
org.gjt.sp.jedit.Macros

public class Macros extends Object
This class records and runs macros.

It also contains a few methods useful for displaying output messages or obtaining input from a macro:

Note that plugins should not use the above methods. Call the methods in the GUIUtilities class instead.
Version:
$Id: Macros.java 25328 2020-05-09 10:17:16Z kpouer $
Author:
Slava Pestov
  • Constructor Details

    • Macros

      public Macros()
  • Method Details

    • showRunScriptDialog

      public static void showRunScriptDialog(View view)
      Prompts for one or more files to run as macros
      Parameters:
      view - The view
      Since:
      jEdit 4.0pre7
    • runScript

      public static void runScript(View view, String path, boolean ignoreUnknown)
      Runs the specified script. Unlike the BeanShell.runScript(View,String,Reader,boolean) method, this method can run scripts supported by any registered macro handler.
      Parameters:
      view - The view
      path - The VFS path of the script
      ignoreUnknown - If true, then unknown file types will be ignored; otherwise, a warning message will be printed and they will be evaluated as BeanShell scripts.
      Since:
      jEdit 4.1pre2
    • message

      public static void message(Component comp, String message)
      Utility method that can be used to display a message dialog in a macro.
      Parameters:
      comp - The component to show the dialog on behalf of, this will usually be a view instance
      message - The message
      Since:
      jEdit 2.7pre2
    • error

      public static void error(Component comp, String message)
      Utility method that can be used to display an error dialog in a macro.
      Parameters:
      comp - The component to show the dialog on behalf of, this will usually be a view instance
      message - The message
      Since:
      jEdit 2.7pre2
    • input

      public static String input(Component comp, String prompt)
      Utility method that can be used to prompt for input in a macro.
      Parameters:
      comp - The component to show the dialog on behalf of, this will usually be a view instance
      prompt - The prompt string
      Since:
      jEdit 2.7pre2
    • input

      public static String input(Component comp, String prompt, String defaultValue)
      Utility method that can be used to prompt for input in a macro.
      Parameters:
      comp - The component to show the dialog on behalf of, this will usually be a view instance
      prompt - The prompt string
      Since:
      jEdit 3.1final
    • confirm

      public static int confirm(Component comp, String prompt, int buttons)
      Utility method that can be used to ask for confirmation in a macro.
      Parameters:
      comp - The component to show the dialog on behalf of, this will usually be a view instance
      prompt - The prompt string
      buttons - The buttons to display - for example, JOptionPane.YES_NO_CANCEL_OPTION
      Since:
      jEdit 4.0pre2
    • confirm

      public static int confirm(Component comp, String prompt, int buttons, int type)
      Utility method that can be used to ask for confirmation in a macro.
      Parameters:
      comp - The component to show the dialog on behalf of, this will usually be a view instance
      prompt - The prompt string
      buttons - The buttons to display - for example, JOptionPane.YES_NO_CANCEL_OPTION
      type - The dialog type - for example, JOptionPane.WARNING_MESSAGE
    • loadMacros

      public static void loadMacros()
      Rebuilds the macros list, and sends a MacrosChanged message (views update their Macros menu upon receiving it)
      Since:
      jEdit 2.2pre4
    • registerHandler

      public static void registerHandler(Macros.Handler handler)
      Adds a macro handler to the handlers list
      Since:
      jEdit 4.0pre6
    • unregisterHandler

      public static void unregisterHandler(Macros.Handler handler)
      Removes a macro handler from the handlers list
      Since:
      jEdit 4.4.1
    • getHandlers

      public static Macros.Handler[] getHandlers()
      Returns an array containing the list of registered macro handlers
      Since:
      jEdit 4.0pre6
    • getHandlerForPathName

      public static Macros.Handler getHandlerForPathName(String pathName)
      Returns the macro handler suitable for running the specified file name, or null if there is no suitable handler.
      Since:
      jEdit 4.1pre3
    • getHandler

      public static Macros.Handler getHandler(String name)
      Returns the macro handler with the specified name, or null if there is no registered handler with that name.
      Since:
      jEdit 4.0pre6
    • getMacroHierarchy

      public static Vector getMacroHierarchy()
      Returns a vector hierarchy with all known macros in it. Each element of this vector is either a macro name string, or another vector. If it is a vector, the first element is a string label, the rest are again, either macro name strings or vectors.
      Since:
      jEdit 2.6pre1
    • getMacroActionSet

      public static ActionSet getMacroActionSet()
      Returns an action set with all known macros in it.
      Since:
      jEdit 4.0pre1
    • getMacro

      public static Macros.Macro getMacro(String macro)
      Returns the macro with the specified name.
      Parameters:
      macro - The macro's name
      Since:
      jEdit 2.6pre1
    • getLastMacro

      public static Macros.Macro getLastMacro()
      Since:
      jEdit 4.3pre1
    • setLastMacro

      public static void setLastMacro(Macros.Macro macro)
      Since:
      jEdit 4.3pre1
    • recordTemporaryMacro

      public static void recordTemporaryMacro(View view)
      Starts recording a temporary macro.
      Parameters:
      view - The view
      Since:
      jEdit 2.7pre2
    • recordMacro

      public static void recordMacro(View view)
      Starts recording a macro.
      Parameters:
      view - The view
      Since:
      jEdit 2.7pre2
    • stopRecording

      public static void stopRecording(View view)
      Stops a recording currently in progress.
      Parameters:
      view - The view
      Since:
      jEdit 2.7pre2
    • runTemporaryMacro

      public static void runTemporaryMacro(View view)
      Runs the temporary macro.
      Parameters:
      view - The view
      Since:
      jEdit 2.7pre2