org.gjt.sp.jedit
Class jEdit

java.lang.Object
  extended by org.gjt.sp.jedit.jEdit

public class jEdit
extends java.lang.Object

The main class of the jEdit text editor.


Method Summary
static void _closeBuffer(View view, Buffer buffer)
          Closes the buffer, even if it has unsaved changes.
static Buffer _getBuffer(java.lang.String path)
          Returns the buffer with the specified path name.
static void addActionSet(ActionSet actionSet)
          Adds a new action set to jEdit's list.
static void addMode(Mode mode)
          Do not call this method.
static void addPluginJAR(java.lang.String path)
          Loads the plugin JAR with the specified path.
static void backupSettingsFile(java.io.File file)
          Backs up the specified file in the settings directory.
static void checkBufferStatus(View view)
          Checks each buffer's status on disk and shows the dialog box informing the user that buffers changed on disk, if necessary.
static boolean closeAllBuffers(View view)
          Closes all open buffers.
static boolean closeAllBuffers(View view, boolean isExiting)
          Closes all open buffers.
static boolean closeBuffer(View view, Buffer buffer)
          Closes a buffer.
static void closeView(View view)
          Closes a view.
static void commitTemporary(Buffer buffer)
          Adds a temporary buffer to the buffer list.
static void exit(View view, boolean reallyExit)
          Exits cleanly from jEdit, prompting the user if any unsaved files should be saved first.
static EditAction getAction(java.lang.String name)
          Returns the specified action.
static ActionContext getActionContext()
          Returns the action context used to store editor actions.
static java.lang.String[] getActionNames()
          Returns all registered action names.
static EditAction[] getActions()
          Deprecated. Call getActionNames() instead
static ActionSet getActionSetForAction(EditAction action)
          Deprecated. Use the form that takes a String instead
static ActionSet getActionSetForAction(java.lang.String action)
          Returns the action set that contains the specified action.
static ActionSet[] getActionSets()
          Returns all registered action sets.
static View getActiveView()
          Returns the currently focused view.
static boolean getBooleanProperty(java.lang.String name)
          Returns the value of a boolean property.
static boolean getBooleanProperty(java.lang.String name, boolean def)
          Returns the value of a boolean property.
static Buffer getBuffer(java.lang.String path)
          Returns the buffer with the specified path name.
static int getBufferCount()
          Returns the number of open buffers.
static Buffer[] getBuffers()
          Returns an array of open buffers.
static java.lang.String getBuild()
          Returns the internal version.
static ActionSet getBuiltInActionSet()
          Returns the set of commands built into jEdit.
static java.awt.Color getColorProperty(java.lang.String name)
          Returns the value of a color property.
static java.awt.Color getColorProperty(java.lang.String name, java.awt.Color def)
          Returns the value of a color property.
static double getDoubleProperty(java.lang.String name, double def)
           
static EditServer getEditServer()
          Returns the edit server instance.
static Buffer getFirstBuffer()
          Returns the first buffer.
static View getFirstView()
          Returns the first view.
static java.awt.Font getFontProperty(java.lang.String name)
          Returns the value of a font property.
static java.awt.Font getFontProperty(java.lang.String name, java.awt.Font def)
          Returns the value of a font property.
static InputHandler getInputHandler()
          Returns the current input handler (key binding to action mapping)
static int getIntegerProperty(java.lang.String name, int def)
          Returns the value of an integer property.
static java.lang.String getJARCacheDirectory()
          Returns the directory where plugin cache files are stored.
static java.lang.String getJEditHome()
          Returns the jEdit install directory.
static Buffer getLastBuffer()
          Returns the last buffer.
static View getLastView()
          Returns the last view.
static Mode getMode(java.lang.String name)
          Returns the edit mode with the specified name.
static Mode[] getModes()
          Returns an array of installed edit modes.
static java.lang.String[] getNotLoadedPluginJARs()
          Returns a list of plugin JARs that are not currently loaded by examining the user and system plugin directories.
static EditPlugin getPlugin(java.lang.String name)
          Returns the plugin with the specified class name.
static EditPlugin getPlugin(java.lang.String name, boolean loadIfNecessary)
          Returns the plugin with the specified class name.
static PluginJAR getPluginJAR(java.lang.String path)
          Returns the JAR with the specified path name.
static PluginJAR[] getPluginJARs()
          Returns an array of installed plugins.
static EditPlugin[] getPlugins()
          Returns an array of installed plugins.
static java.util.Properties getProperties()
          Returns the properties object which contains all known jEdit properties.
static java.lang.String getProperty(java.lang.String name)
          Fetches a property, returning null if it's not defined.
static java.lang.String getProperty(java.lang.String name, java.lang.Object[] args)
          Returns the property with the specified name.
static java.lang.String getProperty(java.lang.String name, java.lang.String def)
          Fetches a property, returning the default value if it's not defined.
static java.lang.String getSettingsDirectory()
          Returns the path of the directory where user-specific settings are stored.
static java.lang.String getVersion()
          Returns the jEdit version as a human-readable string.
static int getViewCount()
          Returns the number of open views.
static View[] getViews()
          Returns an array of all open views.
static boolean isBackgroundModeEnabled()
          Returns true if jEdit was started with the -background command-line switch.
static boolean isMainThread()
          Returns true if the currently running thread is the main thread.
static void main(java.lang.String[] args)
          The main method of the jEdit application.
static Buffer newFile(View view)
          Creates a new `untitled' file.
static Buffer newFile(View view, java.lang.String dir)
          Creates a new `untitled' file.
static View newView(View view)
          Creates a new view.
static View newView(View view, Buffer buffer)
          Creates a new view of a buffer.
static View newView(View view, Buffer buffer, boolean plainView)
          Creates a new view of a buffer.
static View newView(View view, Buffer buffer, View.ViewConfig config)
          Creates a new view.
static Buffer openFile(View view, java.lang.String path)
          Opens a file.
static Buffer openFile(View view, java.lang.String parent, java.lang.String path, boolean readOnly, boolean newFile)
          Deprecated. The openFile() forms with the readOnly parameter should not be used. The readOnly prameter is no longer supported.
static Buffer openFile(View view, java.lang.String parent, java.lang.String path, boolean readOnly, boolean newFile, java.util.Hashtable props)
          Deprecated. The openFile() forms with the readOnly parameter should not be used. The readOnly prameter is no longer supported.
static Buffer openFile(View view, java.lang.String parent, java.lang.String path, boolean newFile, java.util.Hashtable props)
          Opens a file.
static Buffer openFiles(View view, java.lang.String parent, java.lang.String[] args)
          Opens the file names specified in the argument array.
static Buffer openTemporary(View view, java.lang.String parent, java.lang.String path, boolean newFile)
          Opens a temporary buffer.
static void propertiesChanged()
          Reloads various settings from the properties.
static void reloadAllBuffers(View view, boolean confirm)
          Reloads all open buffers.
static void reloadModes()
          Reloads all edit modes.
static void removeActionSet(ActionSet actionSet)
          Removes an action set from jEdit's list.
static void removePluginJAR(PluginJAR jar, boolean exit)
          Unloads the given plugin JAR with the specified path.
static void resetProperty(java.lang.String name)
          Resets a property to its default value.
static void saveAllBuffers(View view)
          Saves all open buffers.
static void saveAllBuffers(View view, boolean confirm)
          Saves all open buffers.
static void saveSettings()
          Saves all user preferences to disk.
static void setBooleanProperty(java.lang.String name, boolean value)
          Sets a boolean property.
static void setColorProperty(java.lang.String name, java.awt.Color value)
          Sets the value of a color property.
static void setDoubleProperty(java.lang.String name, double value)
           
static void setFontProperty(java.lang.String name, java.awt.Font value)
          Sets the value of a font property.
static void setIntegerProperty(java.lang.String name, int value)
          Sets the value of an integer property.
static void setProperty(java.lang.String name, java.lang.String value)
          Sets a property to a new value.
static void setTemporaryProperty(java.lang.String name, java.lang.String value)
          Sets a property to a new value.
static void showMemoryDialog(View view)
          Performs garbage collection and displays a dialog box showing memory status.
static void unsetProperty(java.lang.String name)
          Unsets (clears) a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getVersion

public static java.lang.String getVersion()
Returns the jEdit version as a human-readable string.


getBuild

public static java.lang.String getBuild()
Returns the internal version. MiscUtilities.compareStrings() can be used to compare different internal versions.


main

public static void main(java.lang.String[] args)
The main method of the jEdit application. This should never be invoked directly.

Parameters:
args - The command line arguments

getProperties

public static final java.util.Properties getProperties()
Returns the properties object which contains all known jEdit properties. Note that as of jEdit 4.2pre10, this returns a new collection, not the existing properties instance.

Since:
jEdit 3.1pre4

getProperty

public static final java.lang.String getProperty(java.lang.String name)
Fetches a property, returning null if it's not defined.

Parameters:
name - The property

getProperty

public static final java.lang.String getProperty(java.lang.String name,
                                                 java.lang.String def)
Fetches a property, returning the default value if it's not defined.

Parameters:
name - The property
def - The default value

getProperty

public static final java.lang.String getProperty(java.lang.String name,
                                                 java.lang.Object[] args)
Returns the property with the specified name.

The elements of the args array are substituted into the value of the property in place of strings of the form {n}, where n is an index in the array.

You can find out more about this feature by reading the documentation for the format method of the java.text.MessageFormat class.

Parameters:
name - The property
args - The positional parameters

getBooleanProperty

public static final boolean getBooleanProperty(java.lang.String name)
Returns the value of a boolean property.

Parameters:
name - The property

getBooleanProperty

public static final boolean getBooleanProperty(java.lang.String name,
                                               boolean def)
Returns the value of a boolean property.

Parameters:
name - The property
def - The default value

getIntegerProperty

public static final int getIntegerProperty(java.lang.String name,
                                           int def)
Returns the value of an integer property.

Parameters:
name - The property
def - The default value
Since:
jEdit 4.0pre1

getDoubleProperty

public static double getDoubleProperty(java.lang.String name,
                                       double def)

getFontProperty

public static final java.awt.Font getFontProperty(java.lang.String name)
Returns the value of a font property. The family is stored in the name property, the font size is stored in the namesize property, and the font style is stored in namestyle. For example, if name is view.gutter.font, the properties will be named view.gutter.font, view.gutter.fontsize, and view.gutter.fontstyle.

Parameters:
name - The property
Since:
jEdit 4.0pre1

getFontProperty

public static final java.awt.Font getFontProperty(java.lang.String name,
                                                  java.awt.Font def)
Returns the value of a font property. The family is stored in the name property, the font size is stored in the namesize property, and the font style is stored in namestyle. For example, if name is view.gutter.font, the properties will be named view.gutter.font, view.gutter.fontsize, and view.gutter.fontstyle.

Parameters:
name - The property
def - The default value
Since:
jEdit 4.0pre1

getColorProperty

public static java.awt.Color getColorProperty(java.lang.String name)
Returns the value of a color property.

Parameters:
name - The property name
Since:
jEdit 4.0pre1

getColorProperty

public static java.awt.Color getColorProperty(java.lang.String name,
                                              java.awt.Color def)
Returns the value of a color property.

Parameters:
name - The property name
def - The default value
Since:
jEdit 4.0pre1

setColorProperty

public static void setColorProperty(java.lang.String name,
                                    java.awt.Color value)
Sets the value of a color property.

Parameters:
name - The property name
value - The value
Since:
jEdit 4.0pre1

setProperty

public static final void setProperty(java.lang.String name,
                                     java.lang.String value)
Sets a property to a new value.

Parameters:
name - The property
value - The new value

setTemporaryProperty

public static final void setTemporaryProperty(java.lang.String name,
                                              java.lang.String value)
Sets a property to a new value. Properties set using this method are not saved to the user properties list.

Parameters:
name - The property
value - The new value
Since:
jEdit 2.3final

setBooleanProperty

public static final void setBooleanProperty(java.lang.String name,
                                            boolean value)
Sets a boolean property.

Parameters:
name - The property
value - The value

setIntegerProperty

public static final void setIntegerProperty(java.lang.String name,
                                            int value)
Sets the value of an integer property.

Parameters:
name - The property
value - The value
Since:
jEdit 4.0pre1

setDoubleProperty

public static final void setDoubleProperty(java.lang.String name,
                                           double value)

setFontProperty

public static final void setFontProperty(java.lang.String name,
                                         java.awt.Font value)
Sets the value of a font property. The family is stored in the name property, the font size is stored in the namesize property, and the font style is stored in namestyle. For example, if name is view.gutter.font, the properties will be named view.gutter.font, view.gutter.fontsize, and view.gutter.fontstyle.

Parameters:
name - The property
value - The value
Since:
jEdit 4.0pre1

unsetProperty

public static final void unsetProperty(java.lang.String name)
Unsets (clears) a property.

Parameters:
name - The property

resetProperty

public static final void resetProperty(java.lang.String name)
Resets a property to its default value.

Parameters:
name - The property
Since:
jEdit 2.5pre3

propertiesChanged

public static void propertiesChanged()
Reloads various settings from the properties.


getNotLoadedPluginJARs

public static java.lang.String[] getNotLoadedPluginJARs()
Returns a list of plugin JARs that are not currently loaded by examining the user and system plugin directories.

Since:
jEdit 3.2pre1

getPlugin

public static EditPlugin getPlugin(java.lang.String name)
Returns the plugin with the specified class name.


getPlugin

public static EditPlugin getPlugin(java.lang.String name,
                                   boolean loadIfNecessary)
Returns the plugin with the specified class name. If loadIfNecessary is true, the plugin will be activated in case it has not yet been started.

Since:
jEdit 4.2pre4

getPlugins

public static EditPlugin[] getPlugins()
Returns an array of installed plugins.


getPluginJARs

public static PluginJAR[] getPluginJARs()
Returns an array of installed plugins.

Since:
jEdit 4.2pre1

getPluginJAR

public static PluginJAR getPluginJAR(java.lang.String path)
Returns the JAR with the specified path name.

Parameters:
path - The path name
Since:
jEdit 4.2pre1

addPluginJAR

public static void addPluginJAR(java.lang.String path)
Loads the plugin JAR with the specified path. Some notes about this method:

Parameters:
path - The JAR file path
Since:
jEdit 4.2pre1

removePluginJAR

public static void removePluginJAR(PluginJAR jar,
                                   boolean exit)
Unloads the given plugin JAR with the specified path. Note that calling this at a time other than jEdit shutdown can have unpredictable results if the plugin has not been updated for the jEdit 4.2 plugin API.

Parameters:
jar - The PluginJAR instance
exit - Set to true if jEdit is exiting; enables some shortcuts so the editor can close faster.
Since:
jEdit 4.2pre1

getActionContext

public static ActionContext getActionContext()
Returns the action context used to store editor actions.

Since:
jEdit 4.2pre1

addActionSet

public static void addActionSet(ActionSet actionSet)
Adds a new action set to jEdit's list. Plugins probably won't need to call this method.

Since:
jEdit 4.0pre1

removeActionSet

public static void removeActionSet(ActionSet actionSet)
Removes an action set from jEdit's list. Plugins probably won't need to call this method.

Since:
jEdit 4.2pre1

getBuiltInActionSet

public static ActionSet getBuiltInActionSet()
Returns the set of commands built into jEdit.

Since:
jEdit 4.2pre1

getActionSets

public static ActionSet[] getActionSets()
Returns all registered action sets.

Since:
jEdit 4.0pre1

getAction

public static EditAction getAction(java.lang.String name)
Returns the specified action.

Parameters:
name - The action name

getActionSetForAction

public static ActionSet getActionSetForAction(java.lang.String action)
Returns the action set that contains the specified action.

Parameters:
action - The action
Since:
jEdit 4.2pre1

getActionSetForAction

public static ActionSet getActionSetForAction(EditAction action)
Deprecated. Use the form that takes a String instead


getActions

public static EditAction[] getActions()
Deprecated. Call getActionNames() instead


getActionNames

public static java.lang.String[] getActionNames()
Returns all registered action names.


reloadModes

public static void reloadModes()
Reloads all edit modes.

Since:
jEdit 3.2pre2

getMode

public static Mode getMode(java.lang.String name)
Returns the edit mode with the specified name.

Parameters:
name - The edit mode

getModes

public static Mode[] getModes()
Returns an array of installed edit modes.


openFiles

public static Buffer openFiles(View view,
                               java.lang.String parent,
                               java.lang.String[] args)
Opens the file names specified in the argument array. This handles +line and +marker arguments just like the command line parser.

Parameters:
parent - The parent directory
args - The file names to open
Since:
jEdit 3.2pre4

openFile

public static Buffer openFile(View view,
                              java.lang.String path)
Opens a file. Note that as of jEdit 2.5pre1, this may return null if the buffer could not be opened.

Parameters:
view - The view to open the file in
path - The file path
Since:
jEdit 2.4pre1

openFile

public static Buffer openFile(View view,
                              java.lang.String parent,
                              java.lang.String path,
                              boolean readOnly,
                              boolean newFile)
Deprecated. The openFile() forms with the readOnly parameter should not be used. The readOnly prameter is no longer supported.


openFile

public static Buffer openFile(View view,
                              java.lang.String parent,
                              java.lang.String path,
                              boolean readOnly,
                              boolean newFile,
                              java.util.Hashtable props)
Deprecated. The openFile() forms with the readOnly parameter should not be used. The readOnly prameter is no longer supported.


openFile

public static Buffer openFile(View view,
                              java.lang.String parent,
                              java.lang.String path,
                              boolean newFile,
                              java.util.Hashtable props)
Opens a file. This may return null if the buffer could not be opened for some reason.

Parameters:
view - The view to open the file in
parent - The parent directory of the file
path - The path name of the file
newFile - True if the file should not be loaded from disk be prompted if it should be reloaded
props - Buffer-local properties to set in the buffer
Since:
jEdit 3.2pre10

openTemporary

public static Buffer openTemporary(View view,
                                   java.lang.String parent,
                                   java.lang.String path,
                                   boolean newFile)
Opens a temporary buffer. A temporary buffer is like a normal buffer, except that an event is not fired, the the buffer is not added to the buffers list.

Parameters:
view - The view to open the file in
parent - The parent directory of the file
path - The path name of the file
newFile - True if the file should not be loaded from disk
Since:
jEdit 3.2pre10

commitTemporary

public static void commitTemporary(Buffer buffer)
Adds a temporary buffer to the buffer list. This must be done before allowing the user to interact with the buffer in any way.

Parameters:
buffer - The buffer

newFile

public static Buffer newFile(View view)
Creates a new `untitled' file.

Parameters:
view - The view to create the file in

newFile

public static Buffer newFile(View view,
                             java.lang.String dir)
Creates a new `untitled' file.

Parameters:
view - The view to create the file in
dir - The directory to create the file in
Since:
jEdit 3.1pre2

closeBuffer

public static boolean closeBuffer(View view,
                                  Buffer buffer)
Closes a buffer. If there are unsaved changes, the user is prompted if they should be saved first.

Parameters:
view - The view
buffer - The buffer
Returns:
True if the buffer was really closed, false otherwise

_closeBuffer

public static void _closeBuffer(View view,
                                Buffer buffer)
Closes the buffer, even if it has unsaved changes.

Parameters:
view - The view, may be null
buffer - The buffer
Throws:
java.lang.NullPointerException - if the buffer is null
Since:
jEdit 2.2pre1

closeAllBuffers

public static boolean closeAllBuffers(View view)
Closes all open buffers.

Parameters:
view - The view

closeAllBuffers

public static boolean closeAllBuffers(View view,
                                      boolean isExiting)
Closes all open buffers.

Parameters:
view - The view
isExiting - This must be false unless this method is being called by the exit() method

saveAllBuffers

public static void saveAllBuffers(View view)
Saves all open buffers.

Parameters:
view - The view
Since:
jEdit 4.2pre1

saveAllBuffers

public static void saveAllBuffers(View view,
                                  boolean confirm)
Saves all open buffers.

Parameters:
view - The view
confirm - If true, a confirmation dialog will be shown first
Since:
jEdit 2.7pre2

reloadAllBuffers

public static void reloadAllBuffers(View view,
                                    boolean confirm)
Reloads all open buffers.

Parameters:
view - The view
confirm - If true, a confirmation dialog will be shown first if any buffers are dirty
Since:
jEdit 2.7pre2

_getBuffer

public static Buffer _getBuffer(java.lang.String path)
Returns the buffer with the specified path name. The path name must be an absolute, canonical, path.

Parameters:
path - The path name
Since:
jEdit 4.2pre7
See Also:
MiscUtilities.constructPath(String,String), MiscUtilities.resolveSymlinks(String), getBuffer(String)

getBuffer

public static Buffer getBuffer(java.lang.String path)
Returns the buffer with the specified path name. The path name must be an absolute path. This method automatically resolves symbolic links. If performance is critical, cache the canonical path and call _getBuffer(String) instead.

Parameters:
path - The path name
See Also:
MiscUtilities.constructPath(String,String), MiscUtilities.resolveSymlinks(String)

getBuffers

public static Buffer[] getBuffers()
Returns an array of open buffers.


getBufferCount

public static int getBufferCount()
Returns the number of open buffers.


getFirstBuffer

public static Buffer getFirstBuffer()
Returns the first buffer.


getLastBuffer

public static Buffer getLastBuffer()
Returns the last buffer.


checkBufferStatus

public static void checkBufferStatus(View view)
Checks each buffer's status on disk and shows the dialog box informing the user that buffers changed on disk, if necessary.

Parameters:
view - The view
Since:
jEdit 4.2pre1

getInputHandler

public static InputHandler getInputHandler()
Returns the current input handler (key binding to action mapping)

See Also:
InputHandler

newView

public static View newView(View view)
Creates a new view.

Parameters:
view - An existing view
Since:
jEdit 3.2pre2

newView

public static View newView(View view,
                           Buffer buffer)
Creates a new view of a buffer.

Parameters:
view - An existing view
buffer - The buffer

newView

public static View newView(View view,
                           Buffer buffer,
                           boolean plainView)
Creates a new view of a buffer.

Parameters:
view - An existing view
buffer - The buffer
plainView - If true, the view will not have dockable windows or tool bars.
Since:
4.1pre2

newView

public static View newView(View view,
                           Buffer buffer,
                           View.ViewConfig config)
Creates a new view.

Parameters:
view - An existing view
buffer - A buffer to display, or null
config - Encapsulates the view geometry, split configuration and if the view is a plain view
Since:
jEdit 4.2pre1

closeView

public static void closeView(View view)
Closes a view. jEdit will exit if this was the last open view.


getViews

public static View[] getViews()
Returns an array of all open views.


getViewCount

public static int getViewCount()
Returns the number of open views.


getFirstView

public static View getFirstView()
Returns the first view.


getLastView

public static View getLastView()
Returns the last view.


getActiveView

public static View getActiveView()
Returns the currently focused view.

Since:
jEdit 4.1pre1

isMainThread

public static boolean isMainThread()
Returns true if the currently running thread is the main thread.

Since:
jEdit 4.2pre1

isBackgroundModeEnabled

public static boolean isBackgroundModeEnabled()
Returns true if jEdit was started with the -background command-line switch.

Since:
jEdit 4.0pre4

showMemoryDialog

public static void showMemoryDialog(View view)
Performs garbage collection and displays a dialog box showing memory status.

Parameters:
view - The view
Since:
jEdit 4.0pre1

getJEditHome

public static java.lang.String getJEditHome()
Returns the jEdit install directory.


getSettingsDirectory

public static java.lang.String getSettingsDirectory()
Returns the path of the directory where user-specific settings are stored. This will be null if jEdit was started with the -nosettings command-line switch; do not blindly use this method without checking for a null return value first.


getJARCacheDirectory

public static java.lang.String getJARCacheDirectory()
Returns the directory where plugin cache files are stored.

Since:
jEdit 4.2pre1

backupSettingsFile

public static void backupSettingsFile(java.io.File file)
Backs up the specified file in the settings directory. You should call this on any settings files your plugin writes.

Parameters:
file - The file
Since:
jEdit 4.0pre1

saveSettings

public static void saveSettings()
Saves all user preferences to disk.


exit

public static void exit(View view,
                        boolean reallyExit)
Exits cleanly from jEdit, prompting the user if any unsaved files should be saved first.

Parameters:
view - The view from which this exit was called
reallyExit - If background mode is enabled and this parameter is true, then jEdit will close all open views instead of exiting entirely.

getEditServer

public static EditServer getEditServer()
Returns the edit server instance. You can use this to find out the port number jEdit is listening on.

Since:
jEdit 4.2pre10

addMode

public static void addMode(Mode mode)
Do not call this method. It is only public so that classes in the org.gjt.sp.jedit.syntax package can access it.

Parameters:
mode - The edit mode