⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jedit.java

📁 用java 编写的源码开放的文本编辑器。有很多有用的特性
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			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)	{		/* if value is null:		 * - if default is null, unset user prop		 * - else set user prop to ""		 * else		 * - if default equals value, ignore		 * - if default doesn't equal value, set user		 */		if(value == null)		{			String prop = (String)defaultProps.get(name);			if(prop == null || prop.length() == 0)				props.remove(name);			else				props.put(name,"");		}		else		{			String prop = (String)defaultProps.get(name);			if(value.equals(prop))				props.remove(name);			else				props.put(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)	{		props.remove(name);		defaultProps.put(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)	{		if(defaultProps.get(name) != null)			props.put(name,"");		else			props.remove(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)	{		props.remove(name);	} //}}}	//{{{ propertiesChanged() method	/**	 * Reloads various settings from the properties.	 */	public static void propertiesChanged()	{		initKeyBindings();		Autosave.setInterval(getIntegerProperty("autosave",30));		saveCaret = getBooleanProperty("saveCaret");		//theme = new JEditMetalTheme();		//theme.propertiesChanged();		//MetalLookAndFeel.setCurrentTheme(theme);		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();		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)	{		EditPlugin[] plugins = getPlugins();		for(int i = 0; i < plugins.length; i++)		{			if(plugins[i].getClassName().equals(name))				return plugins[i];		}		return null;	} //}}}	//{{{ 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.JAR)jars.elementAt(i)).getPlugins(vector);		}		EditPlugin[] array = new EditPlugin[vector.size()];		vector.copyInto(array);		return array;	} //}}}	//{{{ getPluginJARs() method	/**	 * Returns an array of installed plugins.	 * @since jEdit 2.5pre3	 */	public static EditPlugin.JAR[] getPluginJARs()	{		EditPlugin.JAR[] array = new EditPlugin.JAR[jars.size()];		jars.copyInto(array);		return array;	} //}}}	//{{{ getPluginJAR() method	/**	 * Returns the JAR with the specified path name.	 * @param path The path name	 * @since jEdit 2.6pre1	 */	public static EditPlugin.JAR getPluginJAR(String path)	{		for(int i = 0; i < jars.size(); i++)		{			EditPlugin.JAR jar = (EditPlugin.JAR)jars.elementAt(i);			if(jar.getPath().equals(path))				return jar;		}		return null;	} //}}}	//{{{ addPluginJAR() method	/**	 * Adds a plugin JAR to the editor.	 * @param plugin The plugin	 * @since jEdit 3.2pre10	 */	public static void addPluginJAR(EditPlugin.JAR plugin)	{		addActionSet(plugin.getActions());		jars.addElement(plugin);	} //}}}	//}}}	//{{{ Action methods	//{{{ addActionSet() method	/**	 * Adds a new action set to jEdit's list. Plugins probably won't	 * need to call this method.	 * @since jEdit 4.0pre1	 */	public static void addActionSet(ActionSet actionSet)	{		actionSets.addElement(actionSet);	} //}}}	//{{{ getActionSets() method	/**	 * Returns all registered action sets.	 * @since jEdit 4.0pre1	 */	public static ActionSet[] getActionSets()	{		ActionSet[] retVal = new ActionSet[actionSets.size()];		actionSets.copyInto(retVal);		return retVal;	} //}}}	//{{{ getAction() method	/**	 * Returns the specified action.	 * @param name The action name	 */	public static EditAction getAction(String name)	{		for(int i = 0; i < actionSets.size(); i++)		{			EditAction action = ((ActionSet)actionSets.elementAt(i))				.getAction(name);			if(action != null)				return action;		}		return null;	} //}}}	//{{{ getActionSetForAction() method	/**	 * Returns the action set that contains the specified action.	 * @param action The action	 * @since jEdit 4.0pre1	 */	public static ActionSet getActionSetForAction(EditAction action)	{		for(int i = 0; i < actionSets.size(); i++)		{			ActionSet set = (ActionSet)actionSets.elementAt(i);			if(set.contains(action))				return set;		}		return null;	} //}}}	//{{{ getActions() method	/**	 * Returns the list of actions registered with the editor.	 */	public static EditAction[] getActions()	{		Vector vec = new Vector();		for(int i = 0; i < actionSets.size(); i++)			((ActionSet)actionSets.elementAt(i)).getActions(vec);		EditAction[] retVal = new EditAction[vec.size()];		vec.copyInto(retVal);		return retVal;	} //}}}	//}}}	//{{{ Edit mode methods	//{{{ reloadModes() method	/**	 * Reloads all edit modes.	 * @since jEdit 3.2pre2	 */	public static void reloadModes()	{		/* Try to guess the eventual size to avoid unnecessary		 * copying */		modes = new Vector(50);		//{{{ Load the global catalog		if(jEditHome == null)			loadModeCatalog("/modes/catalog",true);		else		{			loadModeCatalog(MiscUtilities.constructPath(jEditHome,				"modes","catalog"),false);		} //}}}		//{{{ Load user catalog		if(settingsDirectory != null)		{			File userModeDir = new File(MiscUtilities.constructPath(				settingsDirectory,"modes"));			if(!userModeDir.exists())				userModeDir.mkdirs();			File userCatalog = new File(MiscUtilities.constructPath(				settingsDirectory,"modes","catalog"));			if(!userCatalog.exists())			{				// create dummy catalog				try				{					FileWriter out = new FileWriter(userCatalog);					out.write(jEdit.getProperty("defaultCatalog"));					out.close();				}				catch(IOException io)				{					Log.log(Log.ERROR,jEdit.class,io);				}			}			loadModeCatalog(userCatalog.getPath(),false);		} //}}}		Buffer buffer = buffersFirst;		while(buffer != null)		{			// This reloads the token marker and sends a message			// which causes edit panes to repaint their text areas			buffer.setMode();			buffer = buffer.next;		}	} //}}}	//{{{ getMode() method	/**	 * Returns the edit mode with the specified name.	 * @param name The edit mode	 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -