📄 jedit.java
字号:
return null; else return MessageFormat.format(value,args); } } //}}} //{{{ getBooleanProperty() method /** * Returns the value of a boolean property. * @param name The property */ public static final boolean getBooleanProperty(String name) { return getBooleanProperty(name,false); } //}}} //{{{ getBooleanProperty() method /** * Returns the value of a boolean property. * @param name The property * @param def The default value */ public static final boolean getBooleanProperty(String name, boolean def) { String value = getProperty(name); if(value == null) return def; else if(value.equals("true") || value.equals("yes") || value.equals("on")) return true; else if(value.equals("false") || value.equals("no") || value.equals("off")) return false; else return def; } //}}} //{{{ getIntegerProperty() method /** * Returns the value of an integer property. * @param name The property * @param def The default value * @since jEdit 4.0pre1 */ public static final int getIntegerProperty(String name, int def) { String value = getProperty(name); if(value == null) return def; else { try { return Integer.parseInt(value.trim()); } catch(NumberFormatException nf) { return def; } } } //}}} //{{{ getDoubleProperty() method public static double getDoubleProperty(String name, double def) { String value = getProperty(name); if(value == null) return def; else { try { return Double.parseDouble(value.trim()); } catch(NumberFormatException nf) { return def; } } } //}}} //{{{ getFontProperty() method /** * Returns the value of a font property. The family is stored * in the <code><i>name</i></code> property, the font size is stored * in the <code><i>name</i>size</code> property, and the font style is * stored in <code><i>name</i>style</code>. For example, if * <code><i>name</i></code> is <code>view.gutter.font</code>, the * properties will be named <code>view.gutter.font</code>, * <code>view.gutter.fontsize</code>, and * <code>view.gutter.fontstyle</code>. * * @param name The property * @since jEdit 4.0pre1 */ public static final Font getFontProperty(String name) { return getFontProperty(name,null); } //}}} //{{{ getFontProperty() method /** * Returns the value of a font property. The family is stored * in the <code><i>name</i></code> property, the font size is stored * in the <code><i>name</i>size</code> property, and the font style is * stored in <code><i>name</i>style</code>. For example, if * <code><i>name</i></code> is <code>view.gutter.font</code>, the * properties will be named <code>view.gutter.font</code>, * <code>view.gutter.fontsize</code>, and * <code>view.gutter.fontstyle</code>. * * @param name The property * @param def The default value * @since jEdit 4.0pre1 */ public static final Font getFontProperty(String name, Font def) { String family = getProperty(name); String sizeString = getProperty(name + "size"); String styleString = getProperty(name + "style"); if(family == null || sizeString == null || styleString == null) return def; else { int size, style; try { size = Integer.parseInt(sizeString); } catch(NumberFormatException nf) { return def; } try { style = Integer.parseInt(styleString); } catch(NumberFormatException nf) { return def; } return new Font(family,style,size); } } //}}} //{{{ getColorProperty() method /** * Returns the value of a color property. * @param name The property name * @since jEdit 4.0pre1 */ public static Color getColorProperty(String name) { return getColorProperty(name,Color.black); } //}}} //{{{ getColorProperty() method /** * Returns the value of a color property. * @param name The property name * @param def The default value * @since jEdit 4.0pre1 */ public static Color getColorProperty(String name, Color def) { String value = getProperty(name); if(value == null) return def; else return GUIUtilities.parseColor(value,def); } //}}} //{{{ setColorProperty() method /** * Sets the value of a color property. * @param name The property name * @param value The value * @since jEdit 4.0pre1 */ public static void setColorProperty(String name, Color value) { setProperty(name,GUIUtilities.getColorHexString(value)); } //}}} //{{{ setProperty() method /** * Sets a property to a new value. * @param name The property * @param value The new value */ public static final void setProperty(String name, String value) { propMgr.setProperty(name,value); } //}}} //{{{ setTemporaryProperty() method /** * Sets a property to a new value. Properties set using this * method are not saved to the user properties list. * @param name The property * @param value The new value * @since jEdit 2.3final */ public static final void setTemporaryProperty(String name, String value) { propMgr.setTemporaryProperty(name,value); } //}}} //{{{ setBooleanProperty() method /** * Sets a boolean property. * @param name The property * @param value The value */ public static final void setBooleanProperty(String name, boolean value) { setProperty(name,value ? "true" : "false"); } //}}} //{{{ setIntegerProperty() method /** * Sets the value of an integer property. * @param name The property * @param value The value * @since jEdit 4.0pre1 */ public static final void setIntegerProperty(String name, int value) { setProperty(name,String.valueOf(value)); } //}}} //{{{ setDoubleProperty() method public static final void setDoubleProperty(String name, double value) { setProperty(name,String.valueOf(value)); } //}}} //{{{ setFontProperty() method /** * Sets the value of a font property. The family is stored * in the <code><i>name</i></code> property, the font size is stored * in the <code><i>name</i>size</code> property, and the font style is * stored in <code><i>name</i>style</code>. For example, if * <code><i>name</i></code> is <code>view.gutter.font</code>, the * properties will be named <code>view.gutter.font</code>, * <code>view.gutter.fontsize</code>, and * <code>view.gutter.fontstyle</code>. * * @param name The property * @param value The value * @since jEdit 4.0pre1 */ public static final void setFontProperty(String name, Font value) { setProperty(name,value.getFamily()); setIntegerProperty(name + "size",value.getSize()); setIntegerProperty(name + "style",value.getStyle()); } //}}} //{{{ unsetProperty() method /** * Unsets (clears) a property. * @param name The property */ public static final void unsetProperty(String name) { propMgr.unsetProperty(name); } //}}} //{{{ resetProperty() method /** * Resets a property to its default value. * @param name The property * * @since jEdit 2.5pre3 */ public static final void resetProperty(String name) { propMgr.resetProperty(name); } //}}} //{{{ propertiesChanged() method /** * Reloads various settings from the properties. */ public static void propertiesChanged() { initKeyBindings(); Autosave.setInterval(getIntegerProperty("autosave",30)); saveCaret = getBooleanProperty("saveCaret"); UIDefaults defaults = UIManager.getDefaults(); // give all text areas the same font Font font = getFontProperty("view.font"); //defaults.put("TextField.font",font); defaults.put("TextArea.font",font); defaults.put("TextPane.font",font); // Enable/Disable tooltips ToolTipManager.sharedInstance().setEnabled( jEdit.getBooleanProperty("showTooltips")); initProxy(); // we do this here instead of adding buffers to the bus. Buffer buffer = buffersFirst; while(buffer != null) { buffer.resetCachedProperties(); buffer.propertiesChanged(); buffer = buffer.next; } HistoryModel.propertiesChanged(); KillRing.propertiesChanged(); EditBus.send(new PropertiesChanged(null)); } //}}} //}}} //{{{ Plugin management methods //{{{ getNotLoadedPluginJARs() method /** * Returns a list of plugin JARs that are not currently loaded * by examining the user and system plugin directories. * @since jEdit 3.2pre1 */ public static String[] getNotLoadedPluginJARs() { Vector returnValue = new Vector(); if(jEditHome != null) { String systemPluginDir = MiscUtilities .constructPath(jEditHome,"jars"); String[] list = new File(systemPluginDir).list(); if(list != null) getNotLoadedPluginJARs(returnValue,systemPluginDir,list); } if(settingsDirectory != null) { String userPluginDir = MiscUtilities .constructPath(settingsDirectory,"jars"); String[] list = new File(userPluginDir).list(); if(list != null) { getNotLoadedPluginJARs(returnValue, userPluginDir,list); } } String[] _returnValue = new String[returnValue.size()]; returnValue.copyInto(_returnValue); return _returnValue; } //}}} //{{{ getPlugin() method /** * Returns the plugin with the specified class name. */ public static EditPlugin getPlugin(String name) { return getPlugin(name, false); } //}}} //{{{ getPlugin(String, boolean) method /** * Returns the plugin with the specified class name. If * <code>loadIfNecessary</code> is true, the plugin will be activated in * case it has not yet been started. * @since jEdit 4.2pre4 */ public static EditPlugin getPlugin(String name, boolean loadIfNecessary) { EditPlugin[] plugins = getPlugins(); EditPlugin plugin = null; for(int i = 0; i < plugins.length; i++) { if(plugins[i].getClassName().equals(name)) plugin = plugins[i]; if(loadIfNecessary) { if(plugin instanceof EditPlugin.Deferred) { plugin.getPluginJAR().activatePlugin(); plugin = plugin.getPluginJAR().getPlugin(); break; } } } return plugin; } //}}} //{{{ getPlugins() method /** * Returns an array of installed plugins. */ public static EditPlugin[] getPlugins() { Vector vector = new Vector(); for(int i = 0; i < jars.size(); i++) { EditPlugin plugin = ((PluginJAR)jars.elementAt(i)) .getPlugin(); if(plugin != null) vector.add(plugin); } EditPlugin[] array = new EditPlugin[vector.size()]; vector.copyInto(array); return array; } //}}} //{{{ getPluginJARs() method /** * Returns an array of installed plugins. * @since jEdit 4.2pre1 */ public static PluginJAR[] getPluginJARs() { PluginJAR[] array = new PluginJAR[jars.size()]; jars.copyInto(array); return array; } //}}} //{{{ getPluginJAR() method /** * Returns the JAR with the specified path name. * @param path The path name * @since jEdit 4.2pre1 */ public static PluginJAR getPluginJAR(String path) { for(int i = 0; i < jars.size(); i++) { PluginJAR jar = (PluginJAR)jars.elementAt(i); if(jar.getPath().equals(path)) return jar; } return null; } //}}} //{{{ addPluginJAR() method /** * Loads the plugin JAR with the specified path. Some notes about this * method: * * <ul> * <li>Calling this at a time other than jEdit startup can have * unpredictable results if the plugin has not been updated for the * jEdit 4.2 plugin API. * <li>You must make sure yourself the plugin is not already loaded. * <li>After loading, you just make sure all the plugin's dependencies * are satisified before activating the plugin, using the * {@link PluginJAR#checkDependencies()} method. * </ul> * * @param path The JAR file path * @since jEdit 4.2pre1 */ public static void addPluginJAR(String path) { // backwards compatibility... PluginJAR jar = new EditPlugin.JAR(new File(path)); jars.addElement(jar); jar.init(); EditBus.send(new PluginUpdate(jar,PluginUpdate.LOADED,false)); if(!isMainThread()) { EditBus.send(new DynamicMenuChanged("plugins")); initKeyBindings(); } } //}}} //{{{ addPluginJARsFromDirectory() method /** * Loads all plugins in a directory. * @param directory The directory * @since jEdit 4.2pre1 */ private static void addPluginJARsFromDirectory(String directory) { Log.log(Log.NOTICE,jEdit.class,"Loading plugins from " + directory); File file = new File(directory); if(!(file.exists() && file.isDirectory())) return; String[] plugins = file.list(); if(plugins == null) return; for(int i = 0; i < plugins.length; i++) { String plugin = plugins[i]; if(!plugin.toLowerCase().endsWith(".jar")) continue; String path = MiscUtilities.constructPath(directory,plugin); // remove this when 4.1 plugin API is deprecated if(plugin.equals("EditBuddy.jar") || plugin.equals("PluginManager.jar") || plugin.equals("Firewall.jar") || plugin.equals("Tidy.jar") || plugin.equals("DragAndDrop.jar")) { pluginError(path,"plugin-error.obsolete",null); continue; } addPluginJAR(path); } } //}}} //{{{ removePluginJAR() method /** * 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. * * @param jar The <code>PluginJAR</code> instance * @param exit Set to true if jEdit is exiting; enables some * shortcuts so the editor can close faster. * @since jEdit 4.2pre1 */ public static void removePluginJAR(PluginJAR jar, boolean exit) { if(exit) { jar.uninit(true); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -