Package org.gjt.sp.jedit
Class Macros
- java.lang.Object
-
- org.gjt.sp.jedit.Macros
-
public class Macros extends java.lang.ObjectThis class records and runs macros.It also contains a few methods useful for displaying output messages or obtaining input from a macro:
confirm(Component,String,int)confirm(Component,String,int,int)error(Component,String)input(Component,String)input(Component,String,String)message(Component,String)
GUIUtilitiesclass instead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMacros.HandlerEncapsulates creating and invoking macros in arbitrary scripting languagesstatic classMacros.MacroEncapsulates the macro's label, name and path.static classMacros.RecorderHandles macro recording.
-
Constructor Summary
Constructors Constructor Description Macros()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intconfirm(java.awt.Component comp, java.lang.String prompt, int buttons)Utility method that can be used to ask for confirmation in a macro.static intconfirm(java.awt.Component comp, java.lang.String prompt, int buttons, int type)Utility method that can be used to ask for confirmation in a macro.static voiderror(java.awt.Component comp, java.lang.String message)Utility method that can be used to display an error dialog in a macro.static Macros.HandlergetHandler(java.lang.String name)Returns the macro handler with the specified name, or null if there is no registered handler with that name.static Macros.HandlergetHandlerForPathName(java.lang.String pathName)Returns the macro handler suitable for running the specified file name, or null if there is no suitable handler.static Macros.Handler[]getHandlers()Returns an array containing the list of registered macro handlersstatic Macros.MacrogetLastMacro()static Macros.MacrogetMacro(java.lang.String macro)Returns the macro with the specified name.static ActionSetgetMacroActionSet()Returns an action set with all known macros in it.static java.util.VectorgetMacroHierarchy()Returns a vector hierarchy with all known macros in it.static java.lang.Stringinput(java.awt.Component comp, java.lang.String prompt)Utility method that can be used to prompt for input in a macro.static java.lang.Stringinput(java.awt.Component comp, java.lang.String prompt, java.lang.String defaultValue)Utility method that can be used to prompt for input in a macro.static voidloadMacros()Rebuilds the macros list, and sends a MacrosChanged message (views update their Macros menu upon receiving it)static voidmessage(java.awt.Component comp, java.lang.String message)Utility method that can be used to display a message dialog in a macro.static voidrecordMacro(View view)Starts recording a macro.static voidrecordTemporaryMacro(View view)Starts recording a temporary macro.static voidregisterHandler(Macros.Handler handler)Adds a macro handler to the handlers liststatic voidrunScript(View view, java.lang.String path, boolean ignoreUnknown)Runs the specified script.static voidrunTemporaryMacro(View view)Runs the temporary macro.static voidsetLastMacro(Macros.Macro macro)static voidshowRunScriptDialog(View view)Prompts for one or more files to run as macrosstatic voidstopRecording(View view)Stops a recording currently in progress.static voidunregisterHandler(Macros.Handler handler)Removes a macro handler from the handlers list
-
-
-
Method Detail
-
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, java.lang.String path, boolean ignoreUnknown)
Runs the specified script. Unlike theBeanShell.runScript(View,String,Reader,boolean)method, this method can run scripts supported by any registered macro handler.- Parameters:
view- The viewpath- The VFS path of the scriptignoreUnknown- 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(java.awt.Component comp, java.lang.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 instancemessage- The message- Since:
- jEdit 2.7pre2
-
error
public static void error(java.awt.Component comp, java.lang.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 instancemessage- The message- Since:
- jEdit 2.7pre2
-
input
public static java.lang.String input(java.awt.Component comp, java.lang.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 instanceprompt- The prompt string- Since:
- jEdit 2.7pre2
-
input
public static java.lang.String input(java.awt.Component comp, java.lang.String prompt, java.lang.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 instanceprompt- The prompt string- Since:
- jEdit 3.1final
-
confirm
public static int confirm(java.awt.Component comp, java.lang.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 instanceprompt- The prompt stringbuttons- The buttons to display - for example, JOptionPane.YES_NO_CANCEL_OPTION- Since:
- jEdit 4.0pre2
-
confirm
public static int confirm(java.awt.Component comp, java.lang.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 instanceprompt- The prompt stringbuttons- The buttons to display - for example, JOptionPane.YES_NO_CANCEL_OPTIONtype- 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(java.lang.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(java.lang.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 java.util.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(java.lang.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
-
-